<?xml version="1.0" encoding="UTF-8"?>
<!--=======================================================================
	Copyright:	umlungu consulting (pty) ltd
	Author:		Alan Benington
	Started:	2008-06-14
	Status:		release	
	Version:	2.0.0
	Build:		20080614
	License:	GNU General Public License
	======================================================================= -->

<!--=======================================================================
	Development Notes:
	==================
	20080614:	Initial release.
	=======================================================================	-->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!--=============
	Base template
	============= -->
		
	<xsl:template match="fields">
		<xsl:call-template name="Fields"/>
	</xsl:template>
	
	<xsl:template match="confirms">
		<xsl:call-template name="Fields"/>
	</xsl:template>
	
	<xsl:template match="spacer">
		<tr><td colspan="2"><xsl:call-template name="nobrspace"/></td></tr>
	</xsl:template>
	
	<xsl:template match="fld">
		<xsl:choose>
			<xsl:when test="@type='fld_hidden'"><xsl:call-template name="FldHidden"/></xsl:when>
			<xsl:when test="@type='fld_opt_1to3'"><xsl:call-template name="FldFull"/></xsl:when>
			<xsl:otherwise><xsl:call-template name="FldNormal" /></xsl:otherwise>
		</xsl:choose>
	</xsl:template>
		
	<xsl:template match="label">
		<tr>
			<xsl:choose>
				<xsl:when test="@formsplit!='yes' or not(@formsplit)">	
					<td class="fm-ttl"></td>
					<xsl:choose>
						<xsl:when test="para">
							<td class="fm-ttl"><xsl:apply-templates/></td>			
						</xsl:when>
						<xsl:otherwise>
							<td class="fm-ttl"><xsl:apply-templates/></td>			
						</xsl:otherwise>
					</xsl:choose>
				</xsl:when>
				<xsl:otherwise>
					<td colspan="2" class="split"><xsl:apply-templates/></td>
				</xsl:otherwise>
			</xsl:choose>
		</tr>
	</xsl:template>
	
	<xsl:template match="fld/moreinfo">
		<tr>
			<td></td>
			<td><div class="fm-more"><xsl:apply-templates/></div></td>			
		</tr>
	</xsl:template>
	
	<xsl:template match="fld/hintnormal">
		<xsl:apply-templates/>
	</xsl:template>
	
	<xsl:template match="hintnormal/popup">
		<a>
			<xsl:attribute name="href">
				<xsl:call-template name="popup-action"/>
			</xsl:attribute>
			<xsl:apply-templates/>
		</a>
	</xsl:template>	
	
	<xsl:template match="lnk">
		<xsl:choose>
			<xsl:when test="@type='popup'">
				<a>
					<xsl:attribute name="href">
						<xsl:call-template name="popup-action"/>
					</xsl:attribute>
					<xsl:apply-templates/>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<a>
					<xsl:attribute name="href">
						<xsl:value-of select="$BaseLinkUrl"/><xsl:value-of select="@name"/>
					</xsl:attribute>
					<xsl:apply-templates/>
				</a>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
<!--=======================
	Match templates section
	======================= -->

	<xsl:template match="validation">
		<xsl:if test="parent::*[name()='confirms' or name()='fields']">
			<xsl:choose>
				<xsl:when test="@file and not(@val_obj)">
					<script><xsl:attribute name="src"><xsl:text>scripts/</xsl:text><xsl:value-of select="@src"/></xsl:attribute><xsl:text> </xsl:text></script>
				</xsl:when>
				<xsl:when test="@file and @val_obj">
					<script><xsl:attribute name="src"><xsl:text>scripts/</xsl:text><xsl:value-of select="@src"/></xsl:attribute><xsl:text> </xsl:text></script>
					<script type="text/javascript">
						<xsl:call-template name="Validation">
							<xsl:with-param name="val_obj" select="@val_obj"/>
						</xsl:call-template>
					</script>
				</xsl:when>
				<xsl:otherwise>
					<script type="text/javascript">
						<xsl:call-template name="Validation">
							<xsl:with-param name="val_obj">x_valid</xsl:with-param>
						</xsl:call-template>
					</script>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
	</xsl:template>
	
	<xsl:template match="action">
		<xsl:choose>
			<xsl:when test="@get">
				<xsl:value-of select="@get"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:choose>
					<xsl:when test="@secure='yes'"><xsl:value-of select='$SecureUrl'/></xsl:when>
					<xsl:when test="@device">Output.aspx?device=<xsl:value-of select="@device"/>&amp;link=</xsl:when>
					<xsl:when test="@output"><xsl:value-of select="@output"/>.aspx?device=data&amp;link=</xsl:when>
					<xsl:otherwise><xsl:value-of select="$BaseLinkUrl"/></xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="@link"><xsl:value-of select="@link"/></xsl:when>
					<xsl:otherwise><xsl:value-of select="$link"/></xsl:otherwise>
				</xsl:choose>
				<xsl:if test="@id">
					<xsl:text>&amp;id=</xsl:text><xsl:value-of select="@id"/>
				</xsl:if>
				<xsl:if test="@ref">
					<xsl:value-of select="@ref"/>
				</xsl:if>
				<xsl:apply-templates select="url"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="action/url">
		<xsl:text>&amp;</xsl:text><xsl:value-of select="@name"/><xsl:text>=</xsl:text><xsl:value-of select="."/>
	</xsl:template>
	
	<xsl:template match="fld/prompt">
		<xsl:choose>
			<xsl:when test="image"><xsl:apply-templates mode="www"/></xsl:when>
			<xsl:when test="image"><xsl:apply-templates mode="www"/></xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates/>
				<xsl:choose>
					<xsl:when test="not(@type)"><xsl:text>:</xsl:text></xsl:when>
					<xsl:when test="@type='question'"><xsl:text>?</xsl:text></xsl:when>
					<xsl:when test="@type='none'"><xsl:text></xsl:text></xsl:when>
					<xsl:when test="@type='dots'"><xsl:text>...</xsl:text></xsl:when>
					<xsl:otherwise><xsl:text>:</xsl:text></xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="footerline">
		<tr><td colspan="2" class="nobrspc">
			<xsl:value-of select="."/>
		</td></tr><tr><td colspan="2" class="tr-spc"></td></tr>
	
	</xsl:template>	
	
	<xsl:template match="fld_groups">
		<tr><td colspan="2" class="fm-grp-cnt">
			<table class="fm-grp-hd">
				<colgroup>
					<col class="fm-grp-lbl"/>
					<col>
						<xsl:attribute name="class">
							<xsl:choose>
								<xsl:when test="name()='confirms'">fm-cnf</xsl:when>
								<xsl:otherwise>fm-grp-inp</xsl:otherwise>
							</xsl:choose>
						</xsl:attribute>
					</col>
				</colgroup>
				<xsl:apply-templates select="fld"/>
				<tr class="fm-grp">
					<td class="fm-grp-cnt">&#160;</td>
					<td class="fm-grp-cnt"><img src="styles/ver5/icons/frm_arrow.gif" /></td>
				</tr>
			</table>
		</td></tr>
		<xsl:apply-templates select="fld_group"/>
	</xsl:template>

	<xsl:template match="fld_group">
		<xsl:variable name="thisname"><xsl:value-of select="@name"/></xsl:variable>
		<tr>

			<xsl:attribute name="id">tr_grp_<xsl:value-of select="$thisname"/></xsl:attribute>
			<td colspan="2" class="fm-grp-box">
				<table>
					<xsl:attribute name="class">
						<xsl:choose>
							<xsl:when test="../fld/value = $thisname">fm-grp-show</xsl:when>
							<xsl:when test="not(../fld/value) and position() = 1">fm-grp-show</xsl:when>
							<xsl:otherwise>fm-grp-none</xsl:otherwise>
						</xsl:choose>
					</xsl:attribute>
					<xsl:attribute name="id">grp_<xsl:value-of select="$thisname"/></xsl:attribute>
					<colgroup>
						<col>
							<xsl:attribute name="class">
								<xsl:choose>
									<xsl:when test="name()='confirms'">fm-grp-lbl-ro</xsl:when>
									<xsl:otherwise>fm-grp-lbl</xsl:otherwise>
								</xsl:choose>
							</xsl:attribute>
						</col>
						<col>
							<xsl:attribute name="class">
								<xsl:choose>
									<xsl:when test="name()='confirms'">fm-grp-cnf</xsl:when>
									<xsl:otherwise>fm-grp-inp</xsl:otherwise>
								</xsl:choose>
							</xsl:attribute>
						</col>
					</colgroup>
					<tr>
						<td></td>
						<td class="fm-grp-para">
							<xsl:apply-templates select="*[name()='para']"/>
						</td>
					</tr>
					<xsl:apply-templates select="*[name()!='para']"/>
				</table>
			</td>
		</tr>
	</xsl:template>

	<xsl:template match="fld_group/label">
		<tr>
			<td colspan="2" class="fm-grp-para">
				<div class="fm-hd"><xsl:apply-templates/></div>
			</td>
		</tr>		
	</xsl:template>
	
<!--=======================
	Named templates section
	======================= -->
	
	<xsl:template name="Validation">
		<xsl:param name="val_obj"/>
		<xsl:variable name="thisname">
			<xsl:choose>
				<xsl:when test="../@name"><xsl:value-of select="../@name"/></xsl:when>
				<xsl:otherwise><xsl:value-of select="$name_grp"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:text>function </xsl:text>
		<xsl:choose>
			<xsl:when test="@name"><xsl:value-of select="@name"/></xsl:when>
			<xsl:otherwise><xsl:text>validateForm</xsl:text></xsl:otherwise>
		</xsl:choose>
		<xsl:text>(frm){</xsl:text><xsl:value-of select="$val_obj"/><xsl:text>.Debug("_Validate");try{</xsl:text>
		<xsl:if test="//page/section//fld_groups//fld_group">
			<xsl:for-each select="//page/section//fld_groups">
				var sel_<xsl:value-of select="@selector"/> = frm.<xsl:value-of select="@selector"/>[frm.<xsl:value-of select="@selector"/>.selectedIndex].value;
			</xsl:for-each>
		</xsl:if>
		<!--2005 08-->
		<xsl:for-each select="//content/page/fields/fld[not(@input='readonly')]">
			<xsl:choose>
				<xsl:when test="@type='fld_opt_1to3'">
					<xsl:variable name="hnt"><xsl:value-of select="hintvalid"/></xsl:variable>
					<xsl:variable name="nme"><xsl:text>fld_</xsl:text><xsl:value-of select="@id"/><xsl:text>_</xsl:text></xsl:variable>
					<xsl:if test="mandatory='Y'">
						<xsl:for-each select="subobjs/subwf_obj">
							<xsl:value-of select='$newline'/>
							<xsl:text>if (!</xsl:text><xsl:value-of select="$val_obj"/><xsl:text>.Radio</xsl:text>
							<xsl:text>(frm.</xsl:text>
							<xsl:value-of select="$nme"/><xsl:value-of select="value"/>
							<xsl:text>, "</xsl:text>
							<xsl:value-of select="$hnt"/><xsl:value-of select="prompt"/>
							<xsl:text>"))return false;</xsl:text>
						</xsl:for-each>
					</xsl:if>
				</xsl:when>
				<xsl:otherwise>
					<xsl:if test="mandatory='Y'">
						<xsl:value-of select='$newline'/>
						<xsl:choose>
							<xsl:when test="parent::*[name()='fld_group']">
								<xsl:text>if (sel_</xsl:text><xsl:value-of select="../../@selector"/><xsl:text> == '</xsl:text>
									<xsl:value-of select="../@name"/>
								<xsl:text disable-output-escaping="yes">' &amp;&amp; !</xsl:text><xsl:value-of select="$val_obj"/><xsl:text>.</xsl:text>
							</xsl:when>
							<xsl:otherwise>
								<xsl:text>if (!</xsl:text><xsl:value-of select="$val_obj"/><xsl:text>.</xsl:text>
							</xsl:otherwise>
						</xsl:choose>
						<xsl:call-template name="validation_call"/>
						<xsl:text>(frm.fld_</xsl:text>
						<xsl:value-of select="@id"/>
						<!--
						<xsl:if test="@type='fld_password'">
							<xsl:text> , frm.fld_</xsl:text>
							<xsl:value-of select="@id + 1"/>
						</xsl:if>
						-->
						<xsl:text>, "</xsl:text>
						<xsl:value-of select="hintvalid"/>
						<!-- check one field against another: -->
						<xsl:if test="valid/@checkref">
							<xsl:variable name="chkref" select="valid/@checkref"/>
							<xsl:text>" , frm.fld_</xsl:text>
							<xsl:value-of select="//fields/fld[@name=$chkref]/@id"/>
							<xsl:text> , "</xsl:text>
							<xsl:value-of select="valid/@checktype"/>
						</xsl:if>
						<xsl:text>"))return false;</xsl:text>
					</xsl:if>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
		<xsl:text>}catch(e){</xsl:text><xsl:value-of select="$val_obj"/><xsl:text>.Debug("_validateForm", "error", (typeof(e)=="string")? e : e.description);return false;}</xsl:text>
		<xsl:if test="../@oneclick='yes'">
			<xsl:text>;x_form.SubmitOnce('</xsl:text><xsl:value-of select="$thisname"/><xsl:text>');</xsl:text>
		</xsl:if>
		<xsl:text>return true;}</xsl:text>
	</xsl:template>
	
	<xsl:template name="Fields">
		<xsl:variable name="thisname">
			<xsl:choose>
				<xsl:when test="@name"><xsl:value-of select="@name"/></xsl:when>
				<xsl:otherwise><xsl:value-of select="$name_grp"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<div>
			<form method="post">
				<xsl:attribute name="onkeypress">
					<xsl:text>x_form.KeyPress(this)</xsl:text>
				</xsl:attribute>
				<xsl:choose>
					<xsl:when test="action/@get">
						<xsl:attribute name="method">get</xsl:attribute>
					</xsl:when>		
					<xsl:otherwise>
						<xsl:attribute name="method">post</xsl:attribute>
					</xsl:otherwise>		
				</xsl:choose>
				<xsl:attribute name="name"><xsl:value-of select="$thisname"/></xsl:attribute>
				<xsl:attribute name="action">
					<xsl:apply-templates select="action" />
				</xsl:attribute>
				<xsl:apply-templates select="validation" />
				<xsl:choose>
					<xsl:when test="group">
						<xsl:apply-templates select="group">
							<xsl:with-param name="thisfrm"><xsl:value-of select="$thisname"/></xsl:with-param>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:otherwise>
						<xsl:choose>
							<!--XXXXX Shopping Cart added Here XXXXX -->
							<xsl:when test="//content/page/shopcart/@type='shop_cart_edit'">
								<xsl:apply-templates select="//content/profile/shopcart" mode="ProductEditTable"/>
								<!-- then add normal fields -->
								<table id="fm-tbl">
									<xsl:call-template name="FieldsTable">
										<xsl:with-param name="thisfrm">
											<xsl:value-of select="$thisname"/>
										</xsl:with-param>
									</xsl:call-template>
									<xsl:text>  </xsl:text>
								</table>
							</xsl:when>
							<xsl:when test="//content/page/shopcart/@type='shop_cart_display'">
								<xsl:apply-templates select="//content/profile/shopcart" mode="ProductDisplayTable"/>
								<!-- then add normal fields -->
								<table id="fm-tbl">
									<xsl:call-template name="FieldsTable">
										<xsl:with-param name="thisfrm">
											<xsl:value-of select="$thisname"/>
										</xsl:with-param>
									</xsl:call-template>
									<xsl:text>  </xsl:text>
								</table>
							</xsl:when>
							<!--XXXXX Shopping Cart add end XXXXX -->
							
							<xsl:when test="@type='feedback'">
								<table>
									<xsl:apply-templates select="*[name()!='action' and name()!='validation']" />
								</table>
							</xsl:when>
							<xsl:otherwise>
								<table id="fm-tbl">
									<xsl:call-template name="FieldsTable">
										<xsl:with-param name="thisfrm"><xsl:value-of select="$thisname"/></xsl:with-param>
									</xsl:call-template>
								</table>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:call-template name="FormButtons">
					<xsl:with-param name="which"><xsl:value-of select="@button"/></xsl:with-param>
					<xsl:with-param name="docref"><xsl:value-of select="@target"/></xsl:with-param>
					<xsl:with-param name="islinks"><xsl:value-of select="@links"/></xsl:with-param>
					<xsl:with-param name="thisfrm"><xsl:value-of select="$thisname"/></xsl:with-param>
				</xsl:call-template>
			</form>
		</div>
	</xsl:template>

	<xsl:template name="validation_call">
		<xsl:choose>
			<xsl:when test="valid='validText'"><xsl:text>Text</xsl:text></xsl:when>
			<xsl:when test="valid='validDate'"><xsl:text>Date</xsl:text></xsl:when>
			<xsl:when test="valid='validDateRange'"><xsl:text>DateRange</xsl:text></xsl:when>
			<xsl:when test="valid='validIntCell'"><xsl:text>IntCell</xsl:text></xsl:when>
			<xsl:when test="valid='validCell'"><xsl:text>Cell</xsl:text></xsl:when>
			<xsl:when test="valid='validStripCell'"><xsl:text>StripCell</xsl:text></xsl:when>
			<xsl:when test="valid='validNumber'"><xsl:text>Number</xsl:text></xsl:when>
			<xsl:when test="valid='validDrop'"><xsl:text>Drop</xsl:text></xsl:when>
			<xsl:when test="valid='validRadio'"><xsl:text>Radio</xsl:text></xsl:when>
			<xsl:when test="valid='validCheck'"><xsl:text>Check</xsl:text></xsl:when>
			<xsl:when test="valid='validEmail'"><xsl:text>Email</xsl:text></xsl:when>
			<xsl:when test="valid='validPassword'"><xsl:text>Password</xsl:text></xsl:when>
			<xsl:when test="valid='validPostalCode'"><xsl:text>PostalCode</xsl:text></xsl:when>
			<xsl:when test="valid='validChecks'"><xsl:text>Checks</xsl:text></xsl:when>
			<xsl:when test="valid='validID'"><xsl:text>ID</xsl:text></xsl:when>
			<xsl:when test="valid='validExpiry'"><xsl:text>Expiry</xsl:text></xsl:when>
			<xsl:when test="valid='validFaqXhtml'"><xsl:text>FaqXhtml</xsl:text></xsl:when>
			<xsl:when test="valid='validTextDrop'"><xsl:text>TextDrop</xsl:text></xsl:when>
			<xsl:when test="valid='validNumDrop'"><xsl:text>NumDrop</xsl:text></xsl:when>
			<xsl:otherwise><xsl:text>Text</xsl:text></xsl:otherwise><!--valid='validText'-->
		</xsl:choose>
	</xsl:template>

	<xsl:template match="fields/group">
		<xsl:param name="thisname"/>
		<xsl:if test="@service!='invisible' or not(@service)">
			<div>
				<xsl:attribute name="class">
					<xsl:if test="@highlite='yes'">fm-tbl-hi</xsl:if>
				</xsl:attribute>
				<table id="fm-tbl">
					<xsl:call-template name="FieldsTable">
						<xsl:with-param name="thisfrm"><xsl:value-of select="$thisname"/></xsl:with-param>
					</xsl:call-template>
				</table>
			</div>
		</xsl:if>
	</xsl:template>
	
	<xsl:template match="fields/group[@special]">
		<xsl:param name="thisname"/>
		<xsl:apply-templates select="scheduler"/>
	</xsl:template>

	
	<xsl:template name="FieldsTable">
		<xsl:param name="thisname"/>
		<!--
		<colgroup>
			<col>
				<xsl:attribute name="class">
					<xsl:choose>
						<xsl:when test="name()='confirms'">fm-lbl-ro</xsl:when>
						<xsl:when test="@fieldspacing='large'">fm-lbl-lrg</xsl:when>
						<xsl:when test="@component">fm_xed-lbl</xsl:when>
						<xsl:otherwise>fm-lbl</xsl:otherwise>
					</xsl:choose>
				</xsl:attribute>
			</col>
			<col>
				<xsl:attribute name="class">
					<xsl:choose>
						<xsl:when test="name()='confirms'">fm-cnf</xsl:when>
						<xsl:when test="@fieldspacing='large'">fm-inp-lrg</xsl:when>
						<xsl:when test="@component">fm_xed-inp</xsl:when>
						<xsl:otherwise>fm-inp</xsl:otherwise>
					</xsl:choose>
				</xsl:attribute>
			</col>
		</colgroup>
		-->
		<xsl:apply-templates select="*[name()!='action' and name()!='validation']" />
	</xsl:template>
	
	<xsl:template name="FldHidden">
		<xsl:call-template name="Input"/>
	</xsl:template>
		
	<xsl:template name="FldFull">
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thisval" select="value"/>
		<xsl:variable name="thishints" select="hints"/>
		<tr>
			<td class="fm-lbl"></td>
			<td>
				<table class="opt3">
					<tr>
						<xsl:for-each select="hints/hint">
							<td class="fm-opt3-hd"><xsl:value-of select="."/></td>
						</xsl:for-each>
					</tr>
				</table>
			</td>
		</tr>
		<xsl:for-each select="subobjs/subwf_obj">
			<xsl:variable name="subval"><xsl:text>fld_</xsl:text><xsl:value-of select="$thisid"/><xsl:text>_</xsl:text><xsl:value-of select="value"/></xsl:variable>
			<xsl:variable name="subnme"><xsl:value-of select="$thisname"/><xsl:text>_</xsl:text><xsl:value-of select="value"/></xsl:variable>
			<tr>
				<td class="fm-lbl"><xsl:value-of select="prompt"/></td>
				<td class="fm-inp">
					<table class="opt3">
						<tr>
							<xsl:for-each select="$thishints/hint">
								<td class="fm-opt3">
									<input class="ri-rad" type="radio">
										<xsl:attribute name="type">radio</xsl:attribute>
										<xsl:attribute name="name"><xsl:value-of select="$subnme"/></xsl:attribute>
										<xsl:attribute name="id"><xsl:value-of select="$subval"/></xsl:attribute>
										<xsl:attribute name="value"><xsl:value-of select="@value"/></xsl:attribute>
									</input>
								</td>
							</xsl:for-each>	
						</tr>
					</table>
				</td>
			</tr>
		</xsl:for-each>
	</xsl:template>
		
	<xsl:template name="FldNormal">
		<xsl:apply-templates select="moreinfo"/>
		<tr>
			<td>
				<xsl:attribute name="class">
					<xsl:choose>
						<xsl:when test="parent::*/@type='feedback'">fm-rel-lbl</xsl:when>
						<xsl:otherwise>fm-lbl</xsl:otherwise>
					</xsl:choose>
				</xsl:attribute>
				<xsl:choose>
					<xsl:when test="@type='fld_agree'">
						<xsl:choose>
							<xsl:when test="hintnormal!=''"><xsl:value-of select="hintnormal"/></xsl:when>
							<xsl:otherwise><xsl:text>I accept...</xsl:text></xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:when test="@type='fld_check' and not(@input='readonly' or parent::*[name()='confirms'])">
						<xsl:call-template name="nobrspace"/>
					</xsl:when>
					<xsl:when test="@type='fld_btn_link'">
						<xsl:call-template name="nobrspace"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:choose>
							<xsl:when test="@input='readonly' or parent::*[name()='confirms']">
								<xsl:apply-templates select='prompt'/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:apply-templates select='prompt'/>
								<xsl:if test="@type='fld_chk_multi' and hintnormal!=''">
									<br/><xsl:apply-templates select="hintnormal"/>
								</xsl:if>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:otherwise>
				</xsl:choose>
			</td>
			<td>
				<xsl:attribute name="class">
					<xsl:choose>
						<xsl:when test="parent::*/@type='feedback'">fm-rel-inp</xsl:when>
						<xsl:when test="@type='fld_link'">fm-lnk</xsl:when>
						<xsl:when test="@type='fld_drop'">fm-inp fm-sel</xsl:when>
						<xsl:otherwise>fm-inp</xsl:otherwise>
					</xsl:choose>
				</xsl:attribute>
				<xsl:if test="(@input='readonly' or parent::*[name()='confirms']) and not(@type='fld_opt_fdbck')">
					<xsl:attribute name="class">ro-man</xsl:attribute>
				</xsl:if>
				<xsl:if test="@input='highlight'">
					<xsl:attribute name="class">fm-inp-opt</xsl:attribute>
				</xsl:if>
				<xsl:if test="@input='total'">
					<xsl:attribute name="class">fm-inp-tot</xsl:attribute>
				</xsl:if>
				<xsl:if test="@input='highlight_grp'">
					<xsl:attribute name="class">fm-inp-opt-grp</xsl:attribute>
				</xsl:if>
				<xsl:if test="@input='readonly_grp'">
					<xsl:attribute name="class">ro-man-grp</xsl:attribute>
				</xsl:if>
				<xsl:call-template name="Input"/>
				<xsl:if test="hintnormal!='' and parent::*[name()!='confirms'] and not(@input='readonly' or @type='fld_sms' or @type='fld_agree' or @type='fld_chk_multi')">
					<div class="fm-hint">(<xsl:apply-templates select="hintnormal"/>)</div>
				</xsl:if>
				<xsl:apply-templates select="fld"/>
			</td>
		</tr>
		<xsl:if test="hintnormal!='' and @allowhint='yes'">
			<tr>
				<td></td>
				<td>
					<div class="fm-hint">(<xsl:apply-templates select="hintnormal"/>)</div>
				</td>
			</tr>
		</xsl:if>
	</xsl:template>
	
	<xsl:template name="FldComp">
		<xsl:choose>
			<xsl:when test="parent::*/xedstyle/@val and @type!='fld_xed'">
				<tr>
					<td class="fm_xed_prompt_nrm">
						<xsl:choose>
							<xsl:when test="@type='fld_agree'">
								<xsl:text>I agree...</xsl:text>
							</xsl:when>
							<xsl:when test="@type='fld_check' and not(@input='readonly' or parent::*[name()='confirms'])">
								<xsl:call-template name="nobrspace"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:apply-templates select='prompt'/>
							</xsl:otherwise>
						</xsl:choose>
					</td>
					<td class="fm_xed_fld">
						<xsl:call-template name="Input"/>					
						<xsl:if test="hintnormal!='' and parent::*[name()!='confirms'] and not(@input='readonly' or @type='fld_sms')">
							<div class="fm-hint">(<xsl:apply-templates select="hintnormal"/>)</div>
						</xsl:if>
					</td>
				</tr>
			</xsl:when>
			<xsl:when test="parent::*/xedstyle/@val and @type='fld_xed'">
				<tr>
					<td class="fm_xed_prompt_tol"><xsl:apply-templates select='prompt'/></td>
					<td class="xed_tool_cell_nrm"><div id="divToolbar" class="xed_tool"></div></td>
				</tr>
				<tr>
					<td colspan="2" class="fm_xed_fld">
						<xsl:call-template name="Input"/>					
						<xsl:if test="hintnormal!='' and parent::*[name()!='confirms'] and not(@input='readonly' or @type='fld_sms')">
							<div class="fm-hint">(<xsl:apply-templates select="hintnormal"/>)</div>
						</xsl:if>
					</td>
				</tr>
			</xsl:when>
			<xsl:otherwise>		
				<tr>
					<td class="fm_xed_prompt" colspan="2">
						<xsl:choose>
							<xsl:when test="@type='fld_agree'">
								<xsl:text>I agree...</xsl:text>
							</xsl:when>
							<xsl:when test="@type='fld_check' and not(@input='readonly' or parent::*[name()='confirms'])">
								<xsl:call-template name="nobrspace"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:choose>
									<xsl:when test="@input='readonly' or parent::*[name()='confirms']"><xsl:apply-templates select='prompt'/></xsl:when>
									<xsl:otherwise><xsl:apply-templates select='prompt'/></xsl:otherwise>
								</xsl:choose>
							</xsl:otherwise>
						</xsl:choose>
					</td>
				</tr>
				<tr>
					<td class="fm_xed_fld" colspan="2">
						<xsl:if test="@input='readonly' or parent::*[name()='confirms']">
							<xsl:attribute name="class">ro-man</xsl:attribute>
						</xsl:if>
						<xsl:if test="@input='highlight'">
							<xsl:attribute name="class">fm-inp-opt</xsl:attribute>
						</xsl:if>
						<xsl:if test="@input='total'">
							<xsl:attribute name="class">fm-inp-tot</xsl:attribute>
						</xsl:if>
						<xsl:if test="@input='highlight_grp'">
							<xsl:attribute name="class">fm-inp-opt-grp</xsl:attribute>
						</xsl:if>
						<xsl:if test="@input='readonly_grp'">
							<xsl:attribute name="class">ro-man-grp</xsl:attribute>
						</xsl:if>
						<xsl:call-template name="Input"/>			
					
						<xsl:if test="hintnormal!='' and parent::*[name()!='confirms'] and not(@input='readonly' or @type='fld_sms')">
							<div class="fm-hint">(<xsl:apply-templates select="hintnormal"/>)</div>
						</xsl:if>
					</td>
				</tr>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="Input">
		<xsl:variable name="isConfirm">
			<xsl:choose>
				<xsl:when test="parent::*[name()='confirms']">yes</xsl:when>
				<xsl:otherwise>no</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:choose>
			<xsl:when test="@type='fld_input' or 
							@type='fld_firstname' or 
							@type='fld_initials' or 
							@type='fld_lastname' or 
							@type='fld_email' or
							@type='fld_idno' or 
							@type='fld_pcode' or
							@type='fld_telno' or 
							@type='fld_cellno' or 
							@type='fld_intcellno' or 
							@type='fld_accno' or
							@type='fld_ccardno' or 
							@type='fld_ccardcvv' or 
							@type='fld_ccardexp_text' or
							@type='fld_date_text' or 
							@type='fld_fullname' or 
							@type='fld_addrline' or
							@type='fld_input10' or
							@type='fld_input20' or
							@type='fld_input40' or
							@type='fld_input50' or
							@type='fld_slave' or
							@type='fld_furtherprompt'
							">
				<xsl:call-template name="InputText"/>
			</xsl:when>
			<xsl:when test="@type='fld_hidden'">
				<xsl:call-template name="InputInvisible"/>
			</xsl:when>
			<xsl:when test="@type='fld_logon' or @type='fld_username'">
				<xsl:call-template name="InputUsername"/>
			</xsl:when>
			<xsl:when test="@type='fld_pin' or @type='fld_password'">
				<xsl:call-template name="InputPassword"/>
			</xsl:when>
			<xsl:when test="@type='fld_upload' or @type='fld_file'">
				<xsl:call-template name="InputFile"/>
			</xsl:when>
			<xsl:when test="@type='fld_addr'">
				<xsl:call-template name="InputMulti"/>
			</xsl:when>
			<xsl:when test="@type='fld_email_confirm'">
				<xsl:call-template name="InputEmailConfirm"/>
			</xsl:when>
			<xsl:when test="@type='fld_date_range'">
				<xsl:call-template name="InputDateRange"/>
			</xsl:when>
			<xsl:when test="@type='fld_info' or
							@type='fld_opt_survey_str' or 
							@type='fld_opt_survey_txt' or 
							@type='fld_info_small'
							">
				<xsl:call-template name="Textarea"/>
			</xsl:when>
			<xsl:when test="@type='fld_xml'">
				<xsl:call-template name="TextareaXml"/>
			</xsl:when>
			<xsl:when test="@type='fld_sms'">
				<xsl:call-template name="TextareaSms"/>
			</xsl:when>
			<xsl:when test="@type='fld_yesno' or 
							@type='fld_yesno_input' or
							@type='fld_yesno_explain'
							">
				<xsl:call-template name="SelectRadio"/>
			</xsl:when>
			<xsl:when test="@type='fld_opt_profile' or
							@type='fld_opt_user' or
							@type='fld_opt_pay' or
							@type='fld_property' or
							@type='fld_opt_billdate' or
							@type='fld_opt_black' or
							@type='fld_opt_insure' or
							@type='fld_opt_place' or
							@type='fld_opt_network' or
							@type='fld_opt_delivery' or
							@type='fld_opt_simtype' or
							@type='fld_opt_typereg' or
							@type='fld_opt_taffynet' or
							@type='fld_opt_apply' or
							@type='fld_opt_brands' or
							@type='fld_opt_purchase2' or
							@type='fld_opt_purchase3' or
							@type='fld_opt_ringtone' or
							@type='fld_opt_picmess' or
							@type='fld_opt_profile_status' or
							@type='fld_opt_multi' or
							@type='fld_opt_survey_opt_radio' or
							@type='fld_opt_surveytype'
							">
				<xsl:call-template name="SelectRadioTable"/>
			</xsl:when>
			<xsl:when test="@type='fld_opt_fdbck'">
				<xsl:call-template name="SelectRadioTableFeedback"/>
			</xsl:when>
			<xsl:when test="@type='fld_opt_input'">
				<xsl:call-template name="SelectRadioTableInput"/>
			</xsl:when>
			<xsl:when test="@type='fld_opt_images'">
				<xsl:call-template name="SelectRadioImages"/>
			</xsl:when>
			<xsl:when test="@type='fld_rate'">
				<xsl:call-template name="SelectDropRate"/>
			</xsl:when>
			<xsl:when test="@type='fld_drop' or 
							@type='fld_title' or 
							@type='fld_apply' or 
							@type='fld_income' or 
							@type='fld_period' or 
							@type='fld_banks' or
							@type='fld_bankacctyp' or 
							@type='fld_ccardtyp' or 
							@type='fld_ccardtyp_PP' or
							@type='fld_opt_special' or
							@type='fld_opt_contract' or
							@type='fld_opt_contract_price' or
							@type='fld_opt_data_sms' or
							@type='fld_opt_handset' or
							@type='fld_opt_handset_price' or
							@type='fld_opt_recharge' or
							@type='fld_opt_dates' or
							@type='fld_opt_taffysort' or
							@type='fld_opt_profiles' or
							@type='fld_formoptions' or
							@type='fld_insure' or
							@type='fld_opt_lines' or
							@type='fld_opt_topup' or 
							@type='fld_opt_survey_opt_drop' or
							@type='fld_opt_survey_score_to_10' or
							@type='fld_opt_survey_score_to_5' or
							@type='fld_topup' or
							@type='fld_repeat'
							">
				<xsl:choose>
					<xsl:when test="@input='highlight'">
						<xsl:call-template name="SelectLink"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:call-template name="SelectDrop"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:when test="@type='fld_opt_current_phone' or
							@type='fld_drop_slave'
							">
				<xsl:call-template name="SelectDropSlave"/>
			</xsl:when>
			<xsl:when test="@type='fld_date'">
				<xsl:call-template name="SelectDate"/>
			</xsl:when>
			<xsl:when test="@type='fld_celldrop'">
				<xsl:call-template name="SelectDropInput"/>
			</xsl:when>
			<xsl:when test="@type='fld_opt_survey_rank'">
				<xsl:call-template name="SelectDropMulti"/>
			</xsl:when>
			<xsl:when test="@type='fld_ccardexp'">
				<xsl:call-template name="SelectExpiry"/>
			</xsl:when>
			<xsl:when test="@type='fld_agree'">
				<xsl:call-template name="CheckAgree"/>
			</xsl:when>
			<xsl:when test="@type='fld_check'">
				<xsl:call-template name="Check"/>
			</xsl:when>
			<xsl:when test="@type='fld_check_drop'">
				<xsl:call-template name="CheckSelect"/>
			</xsl:when>
			<xsl:when test="@type='fld_wiz_brands' or 
							@type='fld_chk_multi'
							">
				<xsl:call-template name="CheckMulti"/>
			</xsl:when>
			<xsl:when test="@type='fld_checks' or 
							@type='fld_opt_survey_check'
							">
				<xsl:call-template name="Checks"/>
			</xsl:when>
			<xsl:when test="@type='fld_checklist'">
				<xsl:call-template name="CheckList"/>
			</xsl:when>
			<xsl:when test="@type='fld_btn_link' or 
							@type='fld_btn'
							">
				<xsl:call-template name="InputButton"/>
			</xsl:when>
			<xsl:when test="@type='fld_link'">
				<xsl:call-template name="InputLink"/>
			</xsl:when>
			<xsl:when test="@type='fld_opt_feedback' or 
							@type='fld_opt_1to5' or
							@type='fld_opt_1to3'
							">
				<xsl:call-template name="SelectRadioMulti"/>
			</xsl:when>
			<xsl:when test="@type='fld_trivalue'">
				<xsl:call-template name="CheckTri"/>
			</xsl:when>
			<xsl:when test="@type='fld_list'">
				<ul class="para-ls"><xsl:apply-templates select="fld_list/bull"/></ul>
			</xsl:when>
			<xsl:when test="@type='fld_xed'"> 
				<xsl:call-template name="x_editor"/>
			</xsl:when>
			<xsl:when test="@type='fld_input_drop'"> 
				<xsl:call-template name="InputTextSelectDrop"/>
			</xsl:when>
			<xsl:when test="@type='fld_input_multi'"> 
				<xsl:call-template name="InputTextMulti"/>
			</xsl:when>
			<xsl:when test="@type='fld_input_three'"> 
				<xsl:call-template name="InputTextThree"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="InputDefault"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
		
	<xsl:template name="InputDefault">
		<xsl:call-template name="InputText"/>
	</xsl:template>
	
	<xsl:template name="InputText">
		<input type="Text">
			<xsl:call-template name="input_entry"/>
			<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
			<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
			<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
		</input>
	</xsl:template>
	
	<xsl:template name="InputTextMulti">
		<xsl:variable name="thisname" select="@name"/>
		<table>
			<xsl:for-each select="subobjs/subwf_obj">
				<tr>
					<td>
						<xsl:value-of select="prompt"/>
					</td>
				</tr>
				<tr>
					<td>
						<input type="Text">
							<xsl:call-template name="input_entry"/>
							<xsl:attribute name="name"><xsl:value-of select="$thisname"/><xsl:value-of select="@name"/></xsl:attribute>
							<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
						</input>
					</td>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:template>
	
	<xsl:template name="InputTextThree">
		<xsl:variable name="thisname" select="@name"/>
		<input type="Text">
			<xsl:call-template name="input_entry"/>
			<xsl:attribute name="name"><xsl:value-of select="$thisname"/><xsl:text>Most</xsl:text></xsl:attribute>
			<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
		</input><span> (Most)</span>
		<br/><br/>
		<input type="Text">
			<xsl:call-template name="input_entry"/>
			<xsl:attribute name="name"><xsl:value-of select="$thisname"/></xsl:attribute>
			<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
		</input>
		<br/><br/>
		<input type="Text">
			<xsl:call-template name="input_entry"/>
			<xsl:attribute name="name"><xsl:value-of select="$thisname"/><xsl:text>Least</xsl:text></xsl:attribute>
			<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
		</input><span> (Least)</span>
	</xsl:template>
	
	<xsl:template name="InputTextSelectDrop">
		<div style="float:left;">
			<xsl:call-template name="InputText"/>
		</div>
		<div style="float:left;">
			<xsl:call-template name="nobrspace"/>
			<xsl:value-of select="hintsub"/>
			<xsl:call-template name="nobrspace"/>
			<xsl:call-template name="SelectDrop">
				<xsl:with-param name="is_id">
					<xsl:text>_drop</xsl:text>				
				</xsl:with-param>
			</xsl:call-template>
		</div>
	</xsl:template>

	<xsl:template name="InputInvisible">
		<input type="Hidden">
			<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
			<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
			<xsl:attribute name="size"><xsl:value-of select="length"/></xsl:attribute>
			<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
		</input>
	</xsl:template>

	<xsl:template name="InputUsername">
		<input type="Text">
			<xsl:call-template name="input_entry"/>
			<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
			<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
			<xsl:attribute name="size"><xsl:value-of select="length"/></xsl:attribute>
			<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
			<!--<xsl:attribute name="onclick">javascript:this.select()</xsl:attribute>-->
		</input>
	</xsl:template>

	<xsl:template name="InputPassword">
		<input type="Password">
			<xsl:call-template name="input_entry"/>
			<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
			<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
			<xsl:attribute name="size"><xsl:value-of select="length"/></xsl:attribute>
			<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
		</input>
	</xsl:template>
		
	<xsl:template name="InputFile">
		<input type="File">
			<xsl:call-template name="input_entry"/>
			<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
			<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
			<xsl:attribute name="size"><xsl:value-of select="length"/></xsl:attribute>
			<xsl:attribute name="dir"><xsl:value-of select="value"/></xsl:attribute>
		</input>
	</xsl:template>
	
	<xsl:template name="InputMulti">
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thislen" select="length"/>
		<xsl:call-template name="input_hidden">
			<xsl:with-param name="nme"><xsl:value-of select="$thisname"/></xsl:with-param>
			<xsl:with-param name="id"><xsl:value-of select="$thisid"/></xsl:with-param>
		</xsl:call-template>
		<xsl:choose>
			<xsl:when test="@input='readonly' or parent::*[name()='confirms']">
				<div class="inp-mlti">
					<xsl:for-each select='subobjs/subwf_obj'>
						<xsl:value-of select="value"/><br/>
					</xsl:for-each>
				</div>
			</xsl:when>
			<xsl:otherwise>
				<table>
					<colgroup>
						<col/>
						<col/>
					</colgroup>
					<xsl:for-each select='subobjs/subwf_obj'>
						<tr><td>
							<xsl:call-template name="input_calc">
								<xsl:with-param name="type">text</xsl:with-param>
								<xsl:with-param name="calc">calc_wf_multi</xsl:with-param>
								<xsl:with-param name="nme"><xsl:value-of select='$thisname'/><xsl:value-of select='prompt'/></xsl:with-param>
								<xsl:with-param name="id"><xsl:value-of select='$thisid'/></xsl:with-param>
								<xsl:with-param name="length"><xsl:value-of select="length"/></xsl:with-param>
								<xsl:with-param name="value"><xsl:value-of select="value"/></xsl:with-param>
							</xsl:call-template>
							</td>
						</tr>
					</xsl:for-each>
				</table>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
						
	<xsl:template name="InputEmailConfirm">
		<table>
			<tr>
				<td valign="top">
					<xsl:if test="parent::*[name()!='confirms']">
						<input type="checkbox" >
							<xsl:call-template name="input_entry"/>
							<xsl:attribute name="id">fld_<xsl:value-of select="@id"/>_check</xsl:attribute>
							<xsl:attribute name="name"><xsl:value-of select="@name"/>_check</xsl:attribute>
							<xsl:attribute name="onclick">javascript:x_form.SetEmailConfirm('fld_<xsl:value-of select="@id"/>', this);</xsl:attribute>
						</input>
					</xsl:if>
					<xsl:text>Yes, I would</xsl:text>
				</td>
			</tr>
			<tr>
				<td valign="top">
					<input type="Text">
						<xsl:call-template name="input_entry"/>
						<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
						<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
						<xsl:attribute name="size"><xsl:value-of select="length"/></xsl:attribute>
						<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
						<xsl:attribute name="disabled"><xsl:text>true</xsl:text></xsl:attribute>
					</input>
				</td>
			</tr>
		</table>
	</xsl:template>

	<xsl:template name="InputDateRange">
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thisval" select="value"/>

		<table>
			<!-- rather than hidden fields to have the to and from values, calculate these server-side for now
			<input type="Hidden">
				<xsl:attribute name="name"><xsl:value-of select="@name"/>_from</xsl:attribute>
				<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
				<xsl:attribute name="value"><xsl:value-of select="value/from"/></xsl:attribute>
			</input>
			<input type="Hidden">
				<xsl:attribute name="name"><xsl:value-of select="@name"/>_to</xsl:attribute>
				<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
				<xsl:attribute name="value"><xsl:value-of select="value/to"/></xsl:attribute>
			</input>
			-->
			<xsl:for-each select="subobjs/subwf_obj">
				<tr>
					<td width="4">
						<input type="Radio"> 
							<xsl:call-template name="input_entry"/>
							<xsl:attribute name="id">fld_<xsl:value-of select="$thisid"/></xsl:attribute>
							<xsl:attribute name="name"><xsl:value-of select="$thisname"/></xsl:attribute>
							<xsl:attribute name="value"><xsl:value-of select="@name"/></xsl:attribute>
						</input>
					</td>
					<td align="left"><xsl:value-of select="prompt"/></td>
				</tr>
				<tr>
					<td><xsl:call-template name="nobrspace"/></td>
					<td>
						<xsl:choose>
							<xsl:when test="@type='fld_date'">
								<xsl:call-template name="SelectDate">
									<xsl:with-param name="issub">yes</xsl:with-param>
									<xsl:with-param name="thisid"><xsl:value-of select="$thisid"/></xsl:with-param>
								</xsl:call-template>
							</xsl:when>
							<xsl:when test="@type='fld_input'">
								<xsl:call-template name="InputText"/>
							</xsl:when>
							<xsl:when test="@type='fld_drop'">
								<xsl:call-template name="SelectDrop"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:call-template name="InputDefault"/>
							</xsl:otherwise>
						</xsl:choose>
					</td>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:template>

	<xsl:template name="Textarea">
		<textarea wrap="soft">
			<xsl:call-template name="input_entry"/>
			<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
			<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
			<xsl:value-of select='value'/>
		</textarea>
	</xsl:template>

	<xsl:template name="TextareaXml">
		<textarea wrap='soft'>
			<xsl:call-template name="input_entry"/>
			<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
			<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
			<xsl:attribute name='cols'><xsl:value-of select='length'/></xsl:attribute>
			<xsl:attribute name='rows'><xsl:value-of select='height'/></xsl:attribute>
			<xsl:apply-templates select="value" mode="xml" />
		</textarea>
	</xsl:template>

	<xsl:template match="value" mode="xml">
		<xsl:copy-of select="node()" />
	</xsl:template>

	<xsl:template name="TextareaSms">
		<textarea wrap="soft">
			<xsl:call-template name="input_entry"/>
			<xsl:attribute name="onkeyup">javascript:x_form.SetSmsRemain(this, '<xsl:value-of select="hintnormal"/>');</xsl:attribute>
			<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
			<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
			<xsl:value-of select="value"/>
		</textarea>
		<br/>
		<input type="Text">
			<xsl:attribute name="class">
				<xsl:choose>
					<xsl:when test="parent::*[name()='relinf']">ri-inp-sp</xsl:when>
					<xsl:otherwise>i-t</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
			<xsl:attribute name="id">fld_<xsl:value-of select="@id"/>_count</xsl:attribute>
			<xsl:attribute name="name"><xsl:value-of select="@name"/>_count</xsl:attribute>
			<xsl:attribute name="value">160</xsl:attribute>
			<xsl:attribute name="readonly"><xsl:text>true</xsl:text></xsl:attribute>
		</input>
		<xsl:choose>
			<xsl:when test="parent::*[name()='relinf']">
				<div class="ri-lbl sp">Characters</div>
			</xsl:when>
			<xsl:otherwise><xsl:text> (Characters remaining)</xsl:text></xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="SelectRadio">
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thisval" select="value"/>
		<xsl:variable name="visibility" select="@visibility"/>
		<xsl:call-template name="input_hidden">
			<xsl:with-param name="nme"><xsl:value-of select="@name"/></xsl:with-param>
			<xsl:with-param name="id"><xsl:value-of select="@id"/></xsl:with-param>
		</xsl:call-template>
		<xsl:choose>
			<xsl:when test="@input='readonly' or parent::*[name()='confirms']">
				<input type="Text">
					<xsl:call-template name="input_entry"/>
					<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
					<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
					<xsl:attribute name="size"><xsl:value-of select="length"/></xsl:attribute>
					<xsl:attribute name="value"><xsl:value-of select="subobjs/subwf_obj[value=$thisval]/prompt"/></xsl:attribute>
				</input>
			</xsl:when>
			<xsl:otherwise>
				<xsl:for-each select="subobjs/subwf_obj">
					<xsl:call-template name="input_calc">
						<xsl:with-param name="type">radio</xsl:with-param>
						<xsl:with-param name="calc">calc_wf_radio</xsl:with-param>
						<xsl:with-param name="nme"><xsl:value-of select="$thisname"/></xsl:with-param>
						<xsl:with-param name="id"><xsl:value-of select="$thisid"/></xsl:with-param>
						<xsl:with-param name="value"><xsl:value-of select="$thisval"/></xsl:with-param>
						<xsl:with-param name="visibility"><xsl:value-of select="$visibility"/></xsl:with-param>
					</xsl:call-template>
					<xsl:value-of select="prompt"/>
				</xsl:for-each>
				<xsl:if test="@type='fld_yesno_input'">
					<br/>
					<input type="Text">
						<xsl:call-template name="input_entry"/>
						<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/>_input</xsl:attribute>
						<xsl:attribute name='name'><xsl:value-of select='@name'/>_Input</xsl:attribute>
						<xsl:value-of select='value'/>
					</input>
				</xsl:if>
				<xsl:if test="@type='fld_yesno_explain'">
					<br/><xsl:text>Please explain...</xsl:text><br/>
					<textarea wrap="soft">
						<xsl:call-template name="input_entry"/>
						<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/>_explain</xsl:attribute>
						<xsl:attribute name='name'><xsl:value-of select='@name'/>_Explain</xsl:attribute>
						<xsl:value-of select='value'/>
					</textarea>
				</xsl:if>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="SelectRadioMulti">
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thisval" select="value"/>
		<xsl:call-template name="input_hidden">
			<xsl:with-param name="nme"><xsl:value-of select="@name"/></xsl:with-param>
			<xsl:with-param name="id"><xsl:value-of select="@id"/></xsl:with-param>
		</xsl:call-template>
		<xsl:choose>
			<xsl:when test="@input='readonly' or parent::*[name()='confirms']">
				<input type="Text">
					<xsl:call-template name="input_entry"/>
					<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
					<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
					<xsl:attribute name="size"><xsl:value-of select="length"/></xsl:attribute>
					<xsl:attribute name="value"><xsl:value-of select="subobjs/subwf_obj[value=$thisval]/prompt"/></xsl:attribute>
				</input>
			</xsl:when>
			<xsl:when test="@type='fld_opt_feedback'">
				<!-- feedback box -->
				<div class="feed">Was this content useful?</div>
				<div class="feed">
					<img id="feed1" src="images/feed1.gif" width="20" height="20"/>
					<img id="feed3" src="images/feed3.gif" width="20" height="20"/>
					<img id="feed5" src="images/feed5.gif" width="20" height="20"/>
				</div>
				<div class="ri-r-d">
					<xsl:for-each select="subobjs/subwf_obj">
						<input class="ri-rad" type="radio">
							<xsl:attribute name="type">radio</xsl:attribute>
							<xsl:attribute name="name"><xsl:value-of select="$thisname"/></xsl:attribute>
							<xsl:attribute name="id"><xsl:value-of select="$thisid"/></xsl:attribute>
							<xsl:attribute name="value"><xsl:value-of select="position()"/></xsl:attribute>
						</input>
					</xsl:for-each>
				</div>
			</xsl:when>
			<xsl:otherwise>
				<!-- not yet implemented for normal pages -->
				<table>
					<xsl:for-each select="subobjs/subwf_obj">
						<tr>
							<td><xsl:value-of select="prompt"/></td>
							<td>
								<input class="ri-rad" type="radio">
									<xsl:attribute name="type">radio</xsl:attribute>
									<xsl:attribute name="name"><xsl:value-of select="$thisname"/></xsl:attribute>
									<xsl:attribute name="id"><xsl:value-of select="$thisid"/></xsl:attribute>
									<xsl:attribute name="value"><xsl:value-of select="position()"/></xsl:attribute>
								</input>
							</td>
						</tr>
					</xsl:for-each>
				</table>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="SelectRadioTable">
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thisval" select="value"/>
		<xsl:variable name="visibility" select="@visibility"/>
		
		<xsl:choose>
			<xsl:when test="@input='readonly' or parent::*[name()='confirms']">
				<input type="Text">
					<xsl:call-template name="input_entry"/>
					<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
					<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
					<xsl:attribute name="size">40</xsl:attribute>
					<xsl:attribute name="value"><xsl:value-of select="subobjs/subwf_obj[value=$thisval]/prompt"/></xsl:attribute>
				</input>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="input_hidden">
					<xsl:with-param name="nme"><xsl:value-of select="@name"/></xsl:with-param>
					<xsl:with-param name="id"><xsl:value-of select="@id"/></xsl:with-param>
				</xsl:call-template>
				<table>
					<colgroup>
						<col>
							<xsl:attribute name="class">
								<xsl:choose>
									<xsl:when test="parent::*/@fieldspacing='xlarge'"><xsl:text>fm-rad-xlrg</xsl:text></xsl:when>
									<xsl:when test="parent::*/@fieldspacing!='large' or not(parent::*/@fieldspacing)"><xsl:text>fm-rad</xsl:text></xsl:when>
									<xsl:otherwise><xsl:text>fm-rad-lrg</xsl:text></xsl:otherwise>
								</xsl:choose>									
							</xsl:attribute>
						</col>
						<col>
							<xsl:attribute name="class">
								<xsl:choose>
									<xsl:when test="parent::*/@fieldspacing='xlarge'"><xsl:text>fm-rad-pr-xlrg</xsl:text></xsl:when>
									<xsl:when test="parent::*/@fieldspacing!='large' or not(parent::*/@fieldspacing)"><xsl:text>fm-rad-pr</xsl:text></xsl:when>
									<xsl:otherwise><xsl:text>fm-rad-pr-lrg</xsl:text></xsl:otherwise>
								</xsl:choose>									
							</xsl:attribute>
						</col>
					</colgroup>
					<xsl:for-each select="subobjs/subwf_obj">
						<tr>
							<td width="4">								
								<xsl:call-template name="input_calc">
									<xsl:with-param name="type">radio</xsl:with-param>
									<xsl:with-param name="nme"><xsl:value-of select="$thisname"/></xsl:with-param>
									<xsl:with-param name="id"><xsl:value-of select="$thisid"/></xsl:with-param>
									<xsl:with-param name="visibility"><xsl:value-of select="$visibility"/></xsl:with-param>
									<xsl:with-param name="value"><xsl:value-of select="$thisval"/></xsl:with-param>
									<xsl:with-param name="showprompt"><xsl:value-of select="@showprompt"/></xsl:with-param>
									<xsl:with-param name="hideprompt"><xsl:value-of select="@hideprompt"/></xsl:with-param>
									<xsl:with-param name="calc">calc_wf_radio</xsl:with-param>
								</xsl:call-template>
							</td>
							<td align="left" class="fm-pr"><xsl:apply-templates select="prompt"/>
								<xsl:if test="fld">
									<xsl:call-template name='nobrspace'/>
									<xsl:value-of select="fld/prompt"/><br/>
									<xsl:choose>
										<xsl:when test="fld/@type='fld_info'">
											<br/>
											<textarea wrap="soft">
												<xsl:call-template name="input_entry"/>
												<xsl:attribute name="name"><xsl:value-of select="fld/@name"/></xsl:attribute>
												<xsl:value-of select='fld/value'/>
											</textarea>
										</xsl:when>
										<xsl:otherwise>
											<br/>
											<input type="Text">
												<xsl:call-template name="input_entry"/>
												<xsl:attribute name="name"><xsl:value-of select="fld/@name"/></xsl:attribute>
												<xsl:attribute name="value"><xsl:value-of select="fld/value"/></xsl:attribute>
											</input>
										</xsl:otherwise>
									</xsl:choose>
								</xsl:if>
							</td>
						</tr>
						<xsl:if test="@input='yes'">
							<tr>
								<td width="4"><xsl:call-template name="nobrspace"/></td>
								<td align="left">
									<textarea wrap="soft">
										<xsl:call-template name="input_entry"/>
										<xsl:attribute name='id'>fld_<xsl:value-of select='subobjs/subwf_obj/@id'/></xsl:attribute>
										<xsl:attribute name='name'><xsl:value-of select='subobjs/subwf_obj/@name'/></xsl:attribute>
										<xsl:attribute name='cols'><xsl:value-of select='subobjs/subwf_obj/length'/></xsl:attribute>
										<xsl:attribute name='rows'><xsl:value-of select='subobjs/subwf_obj/height'/></xsl:attribute>
										<xsl:value-of select='subobjs/subwf_obj/value'/>
									</textarea>
								</td>
							</tr>
						</xsl:if>
					</xsl:for-each>
					<xsl:for-each select="note/ps">
						<tr>
							<td><xsl:call-template name="nobrspace"/></td>
							<td><xsl:value-of select="."/></td>
						</tr>
					</xsl:for-each>
				</table>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="SelectRadioTableFeedback">
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thisval" select="value"/>
		<xsl:variable name="visibility" select="@visibility"/>
		<xsl:choose>
			<xsl:when test="@input='readonly' or parent::*[name()='confirms']">
				<xsl:for-each select='subobjs/subwf_obj'>
					<div class="fm-fdbk-lrg">
						<xsl:apply-templates />
					</div>
				</xsl:for-each>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="input_hidden">
					<xsl:with-param name="nme"><xsl:value-of select="@name"/></xsl:with-param>
					<xsl:with-param name="id"><xsl:value-of select="@id"/></xsl:with-param>
				</xsl:call-template>
				<table>
					<colgroup>
						<col>
							<xsl:attribute name="class">
								<xsl:choose>
									<xsl:when test="parent::*/@fieldspacing!='large' or not(parent::*/@fieldspacing)"><xsl:text>fm-rad</xsl:text></xsl:when>
									<xsl:otherwise><xsl:text>fm-rad-lrg</xsl:text></xsl:otherwise>
								</xsl:choose>									
							</xsl:attribute>
						</col>
						<col>
							<xsl:attribute name="class">
								<xsl:choose>
									<xsl:when test="parent::*/@fieldspacing!='large' or not(parent::*/@fieldspacing)"><xsl:text>fm-rad-pr</xsl:text></xsl:when>
									<xsl:otherwise><xsl:text>fm-rad-pr-lrg</xsl:text></xsl:otherwise>
								</xsl:choose>									
							</xsl:attribute>
						</col>
					</colgroup>
					<xsl:for-each select="subobjs/subwf_obj">
						<tr>
							<td width="4">								
								<xsl:call-template name="input_calc">
									<xsl:with-param name="type">radio</xsl:with-param>
									<xsl:with-param name="calc">calc_wf_radio</xsl:with-param>
									<xsl:with-param name="nme"><xsl:value-of select="$thisname"/></xsl:with-param>
									<xsl:with-param name="id"><xsl:value-of select="$thisid"/></xsl:with-param>
									<xsl:with-param name="visibility"><xsl:value-of select="$visibility"/></xsl:with-param>
									<xsl:with-param name="value"><xsl:value-of select="$thisval"/></xsl:with-param>
									<xsl:with-param name="showprompt"><xsl:value-of select="@showprompt"/></xsl:with-param>
									<xsl:with-param name="hideprompt"><xsl:value-of select="@hideprompt"/></xsl:with-param>
								</xsl:call-template>
							</td>
							<td align="left"><xsl:apply-templates select="prompt"/></td>
						</tr>
						<xsl:if test="@input='yes'">
							<tr>
								<td width="4"><xsl:call-template name="nobrspace"/></td>
								<td align="left">
									<textarea wrap="soft">
										<xsl:call-template name="input_entry"/>
										<xsl:attribute name='id'>fld_<xsl:value-of select='subobjs/subwf_obj/@id'/></xsl:attribute>
										<xsl:attribute name='name'><xsl:value-of select='subobjs/subwf_obj/@name'/></xsl:attribute>
										<xsl:attribute name='cols'><xsl:value-of select='subobjs/subwf_obj/length'/></xsl:attribute>
										<xsl:attribute name='rows'><xsl:value-of select='subobjs/subwf_obj/height'/></xsl:attribute>
										<xsl:value-of select='subobjs/subwf_obj/value'/>
									</textarea>
								</td>
							</tr>
						</xsl:if>
					</xsl:for-each>
					<xsl:for-each select="note/ps">
						<tr>
							<td><xsl:call-template name="nobrspace"/></td>
							<td><xsl:value-of select="."/></td>
						</tr>
					</xsl:for-each>
				</table>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="SelectRadioTableInput">
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thisval" select="value"/>
		<xsl:choose>
			<xsl:when test="@input='readonly' or parent::*[name()='confirms']">
				<input type="Text" size="40">
					<xsl:call-template name="input_entry"/>
					<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
					<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
					<xsl:attribute name="value"><xsl:value-of select="subobjs/subwf_obj[value=$thisval]/prompt"/></xsl:attribute>
				</input>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="input_hidden">
					<xsl:with-param name="nme"><xsl:value-of select="@name"/></xsl:with-param>
					<xsl:with-param name="id"><xsl:value-of select="@id"/></xsl:with-param>
				</xsl:call-template>
				<table>
					<xsl:for-each select="subobjs/subwf_obj">
						<tr>
							<td width="20">
								<xsl:call-template name="input_calc">
									<xsl:with-param name="type">radio</xsl:with-param>
									<xsl:with-param name="calc">calc_wf_radio</xsl:with-param>
									<xsl:with-param name="nme"><xsl:value-of select="$thisname"/></xsl:with-param>
									<xsl:with-param name="id"><xsl:value-of select="$thisid"/></xsl:with-param>
									<xsl:with-param name="value"><xsl:value-of select="$thisval"/></xsl:with-param>
								</xsl:call-template>
							</td>
							<xsl:choose>
								<xsl:when test="@type='input'">
									<td>
										<xsl:call-template name="InputText"/>
									</td>
								</xsl:when>
								<xsl:otherwise>
									<td><xsl:apply-templates select="prompt"/></td>
								</xsl:otherwise>
							</xsl:choose>
						</tr>
					</xsl:for-each>
					<xsl:for-each select="note/ps">
						<tr>
							<td><xsl:call-template name="nobrspace"/></td>
							<td><span class="content-text"><xsl:value-of select="."/></span></td>
						</tr>
					</xsl:for-each>
				</table>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="SelectRadioImages">
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thisval" select="value"/>
		<xsl:choose>
			<xsl:when test="@input='readonly' or parent::*[name()='confirms']">
				<img><xsl:attribute name="src"><xsl:text>images/</xsl:text><xsl:value-of select="subobjs/subwf_obj[value=$thisval]/prompt"/></xsl:attribute></img>
			</xsl:when>
			<xsl:otherwise>
				<xsl:for-each select="subobjs/subwf_obj">
					<div>
						<xsl:call-template name="input_calc">
							<xsl:with-param name="type">radio</xsl:with-param>
							<xsl:with-param name="nme"><xsl:value-of select="$thisname"/></xsl:with-param>
							<xsl:with-param name="id"><xsl:value-of select="$thisid"/></xsl:with-param>
							<xsl:with-param name="value"><xsl:value-of select="$thisval"/></xsl:with-param>
							<!--<xsl:with-param name="selected"><xsl:value-of select="$thissel"/></xsl:with-param>-->
						</xsl:call-template>
						<img><xsl:attribute name="src"><xsl:text>images/</xsl:text><xsl:value-of select="prompt"/></xsl:attribute></img>
					</div>
				</xsl:for-each>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
		
	<xsl:template name="SelectLink">
		<xsl:variable name="thisval" select="value"/>
		<span>
			<xsl:if test="$thisval!='0'">
				<xsl:value-of select="subobjs/subwf_obj[value = $thisval]/prompt"/>
				<xsl:text> (</xsl:text>
					<a>
						<xsl:attribute name="href">
							<xsl:call-template name="popup-link">
								<xsl:with-param name="link" select="$thisval"/>
							</xsl:call-template>
						</xsl:attribute>
						<xsl:text>More Info</xsl:text>
					</a>
				<xsl:text>)</xsl:text>
				<input type="hidden">
					<xsl:attribute name="value"><xsl:value-of select="subobjs/subwf_obj[value = $thisval]/value"/></xsl:attribute>
					<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
				</input>
			</xsl:if>
		</span>
	</xsl:template>
	
	<xsl:template name="SelectDrop">
		<xsl:param name="mandatory"/>
		<xsl:param name="noclass"/>
		<xsl:param name="is_id"/>
		<!--<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisval" select="value"/>-->
		<xsl:variable name="thisid">
			<xsl:choose>
				<xsl:when test="$is_id">
					<xsl:value-of select="@id"/>
					<xsl:value-of select="$is_id"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="@id"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="thisname">
			<xsl:choose>
				<xsl:when test="$is_id">
					<xsl:value-of select="@drop_name"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="@name"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="thisval">
			<xsl:choose>
				<xsl:when test="$is_id">
					<xsl:value-of select="drop_value"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="value"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		
		<xsl:choose>
			<xsl:when test="@input='readonly' or parent::*[name()='confirms']">
				<input type="Text">
					<xsl:call-template name="input_entry"/>
					<xsl:choose>
						<xsl:when test="$is_id">
							<xsl:attribute name="id">fld_<xsl:value-of select="@id"/><xsl:value-of select="$is_id"/></xsl:attribute>
						</xsl:when>
						<xsl:otherwise>
							<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
						</xsl:otherwise>
					</xsl:choose>
					<xsl:attribute name="name"><xsl:value-of select="$thisname"/></xsl:attribute>
					<xsl:attribute name="size">40</xsl:attribute>
					<xsl:attribute name="value">
						<xsl:if test="$thisval!='0'">
							<xsl:value-of select="subobjs/subwf_obj[value = $thisval]/prompt"/>
						</xsl:if>
					</xsl:attribute>
				</input>
			</xsl:when>
			<xsl:otherwise>
				<xsl:variable name="selector"><xsl:value-of select="../@selector"/></xsl:variable>
				<xsl:if test="@name=$selector">
					<script language="javascript">
						function set_drop_<xsl:value-of select="$thisid"/>() {
							<xsl:text>var objNames = new Array();</xsl:text>
							<xsl:for-each select="subobjs/subwf_obj">
								<xsl:text>document.getElementById('tr_grp_</xsl:text><xsl:value-of select="value"/><xsl:text>').style.display='none';</xsl:text>
								<xsl:text>document.getElementById('grp_</xsl:text><xsl:value-of select="value"/><xsl:text>').style.display='none';</xsl:text>
								<xsl:text>objNames[</xsl:text><xsl:value-of select="position()-1"/><xsl:text>] = 'grp_</xsl:text><xsl:value-of select="value"/><xsl:text>';</xsl:text>
							</xsl:for-each>
							<xsl:text>var e = document.getElementById('fld_</xsl:text><xsl:value-of select="$thisid"/><xsl:text>').selectedIndex;</xsl:text>
							document.getElementById(objNames[e]).style.display = 'block';
							document.getElementById('tr_' + objNames[e]).style.display = 'block';
							x_page.Resize();
						}
					</script>
				</xsl:if>
				<select>
					<!--
					<xsl:attribute name="onmouseover">javascript:x_page.DropShowHide(this)</xsl:attribute>
					-->
					<xsl:if test="not($noclass='yes')">
						<xsl:call-template name="select_class">
							<xsl:with-param name="mandatory" select="$mandatory"/>
						</xsl:call-template>
					</xsl:if>
					<xsl:if test="@name=$selector">
						<xsl:attribute name="onchange">set_drop_<xsl:value-of select="$thisid"/>();</xsl:attribute>
					</xsl:if>
					<xsl:if test="@dropref">
						<xsl:choose>
							<xsl:when test="@type='array'">
								<xsl:attribute name="onChange">
									<xsl:text>javascript:x_form.SetDrop(this.value, </xsl:text>
									<xsl:value-of select="@dropref"/><xsl:text>, </xsl:text>
									<xsl:value-of select="arrays/@index"/><xsl:text>, </xsl:text>
									<xsl:value-of select="number(arrays/@source_ordinal)"/><xsl:text>, </xsl:text>
									<xsl:value-of select="arrays/@source"/><xsl:text>, </xsl:text>
									<xsl:value-of select="number(arrays/@target_ordinal)"/><xsl:text>, </xsl:text>
									<xsl:value-of select="arrays/@target"/><xsl:text>);</xsl:text>
								</xsl:attribute>
							</xsl:when>
							<xsl:otherwise>
								<xsl:attribute name="onChange">
									<xsl:text>javascript:setOptions(this.value,</xsl:text><xsl:value-of select="@dropref"/><xsl:text>);</xsl:text>
								</xsl:attribute>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:if>
					<xsl:if test="@type='showfurtherprompt'">
						<xsl:attribute name="onChange">
							<xsl:text>javascript:x_form.ShowBox(this, '</xsl:text><xsl:value-of select="@furtherprompt"/><xsl:text>', '</xsl:text><xsl:value-of select='@showfurtherprompt'/><xsl:text>');</xsl:text>
						</xsl:attribute>
					</xsl:if>
					<xsl:attribute name="id">fld_<xsl:value-of select="$thisid"/></xsl:attribute>
					<xsl:attribute name="name"><xsl:value-of select="$thisname"/></xsl:attribute>
					<xsl:for-each select="subobjs/subwf_obj">
						<option>
							<xsl:attribute name="id">fld_<xsl:value-of select="$thisid"/></xsl:attribute>
							<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
							<xsl:if test="value=$thisval">
								<xsl:attribute name="selected"></xsl:attribute>
							</xsl:if>
							<xsl:value-of select="prompt"/>
							<xsl:value-of select="prompt2"/>
						</option>
					</xsl:for-each>
				</select>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<!-- cloned, simplified and modified from SelectDrop:
			- toggles visibility based on the value selected from a drop down (value = "show", else hide)
			- also, clears or populates the visibility field
			- uses the 'SetVisibility' methid of the javascript ClassNM_Form object
	-->
	<xsl:template name="SelectDropSlave">
		<xsl:param name="mandatory"/>
		<xsl:param name="noclass"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thisval" select="value"/>
		<xsl:variable name="visibilityFld" select="@visibility"/>
		<xsl:choose>
			<xsl:when test="@input='readonly' or parent::*[name()='confirms']">
				<input type="Text">
					<xsl:call-template name="input_entry"/>
					<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
					<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
					<xsl:attribute name="size">40</xsl:attribute>
					<xsl:attribute name="value">
						<xsl:if test="$thisval!='0'">
							<xsl:value-of select="subobjs/subwf_obj[value = $thisval]/prompt"/>
							<xsl:value-of select="subobjs/subwf_obj[value = $thisval]/prompt2"/>
						</xsl:if>
					</xsl:attribute>
				</input>
			</xsl:when>
			<xsl:otherwise>
				<select>
					<xsl:if test="not($noclass='yes')">
						<xsl:call-template name="select_class">
							<xsl:with-param name="mandatory" select="$mandatory"/>
						</xsl:call-template>
					</xsl:if>
					<xsl:attribute name="onChange">
						<xsl:text>javascript:x_form.SetVisibility((this.value == 'show'), '</xsl:text>
						<xsl:value-of select='$visibilityFld'/><xsl:text>', 'fld_</xsl:text>
						<xsl:value-of select="following-sibling::fld[@name=$visibilityFld]/@id"/>
						<xsl:text>', false);</xsl:text>
					</xsl:attribute>
					<xsl:attribute name="id">fld_<xsl:value-of select="$thisid"/></xsl:attribute>
					<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
					<xsl:for-each select="subobjs/subwf_obj">
						<option>
							<xsl:attribute name="id">fld_<xsl:value-of select="$thisid"/></xsl:attribute>
							<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
							<xsl:if test="value=$thisval">
								<xsl:attribute name="selected"></xsl:attribute>
							</xsl:if>
							<xsl:value-of select="prompt"/>
						</option>
					</xsl:for-each>
				</select>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="SelectDropRate">
		<xsl:param name="mandatory"/>
		<xsl:param name="noclass"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thisval" select="value"/>
				<select>
					<xsl:if test="not($noclass='yes')">
						<xsl:call-template name="select_class">
							<xsl:with-param name="mandatory" select="$mandatory"/>
						</xsl:call-template>
					</xsl:if>
						<option id="fld_0" value="0">Rate</option>
						<option id="fld_1" value="1">1</option>
						<option id="fld_2" value="2">2</option>
						<option id="fld_3" value="3">3</option>
						<option id="fld_4" value="4">4</option>
						<option id="fld_5" value="5">5</option>
				</select>
	</xsl:template>
		
	<xsl:template name="SelectDate">
		<xsl:param name="issub">no</xsl:param>
		<xsl:param name="thisname" select="@name"/>
		<xsl:param name="thisid" select="@id"/>
		<xsl:variable name="this_yy" select="substring(value,1,4)" />
		<xsl:variable name="this_mm" select="substring(value,6,2)" />
		<xsl:variable name="this_dd" select="substring(value,9,2)" />
		<xsl:if test="$issub='no'">
			<input type="hidden">
				<xsl:attribute name='name'><xsl:value-of select='$thisname'/></xsl:attribute>
				<xsl:attribute name='id'>fld_<xsl:value-of select='$thisid'/></xsl:attribute>
				<xsl:attribute name='value'><xsl:value-of select='value'/></xsl:attribute>
			</input>
		</xsl:if>
		<!-- Year -->
		<xsl:call-template name="select_date">
			<xsl:with-param name="thisid" select="@id" />
			<xsl:with-param name="which">year</xsl:with-param>
			<xsl:with-param name="thisval" select="$this_yy" />
			<xsl:with-param name="thissub" select="$issub" />
		</xsl:call-template>
		<!-- Month -->
		<xsl:call-template name="select_date">
			<xsl:with-param name="thisid" select="@id" />
			<xsl:with-param name="which">month</xsl:with-param>
			<xsl:with-param name="thisval" select="$this_mm" />
			<xsl:with-param name="thissub" select="$issub" />
		</xsl:call-template>
		<!-- Day -->
		<xsl:call-template name="select_date">
			<xsl:with-param name="thisid" select="@id" />
			<xsl:with-param name="which">day</xsl:with-param>
			<xsl:with-param name="thisval" select="$this_dd" />
			<xsl:with-param name="thissub" select="$issub" />
		</xsl:call-template>
	</xsl:template>
	
	<xsl:template name="SelectDropInput">
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thisval" select="value"/>
		<xsl:variable name="thispreval" select="substring($thisval, 1, 3)"/>
		<xsl:variable name="thissufval" select="substring($thisval, 4)"/>
		<xsl:choose>
			<xsl:when test="@input='readonly' or parent::*[name()='confirms']">
				<input type="Text">
					<xsl:call-template name="input_entry"/>
					<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
					<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
					<xsl:attribute name="size">40</xsl:attribute>
					<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
				</input>
			</xsl:when>
			<xsl:otherwise>
				<select>
					<xsl:call-template name="select_class"/>
					<xsl:if test="@dropref">
						<xsl:choose>
							<xsl:when test="@type='array'">
								<xsl:attribute name="onchange">
									<xsl:text>javascript:x_form.SetDrop(this.value, </xsl:text>
									<xsl:value-of select="@dropref"/><xsl:text>, </xsl:text>
									<xsl:value-of select="arrays/@index"/><xsl:text>, </xsl:text>
									<xsl:value-of select="number(arrays/@source_ordinal)"/><xsl:text>, </xsl:text>
									<xsl:value-of select="arrays/@source"/><xsl:text>, </xsl:text>
									<xsl:value-of select="number(arrays/@target_ordinal)"/><xsl:text>, </xsl:text>
									<xsl:value-of select="arrays/@target"/><xsl:text>);</xsl:text>
								</xsl:attribute>
							</xsl:when>
							<xsl:otherwise>
								<xsl:attribute name="onChange">
									<xsl:text>javascript:setOptions(this.value,</xsl:text><xsl:value-of select="@dropref"/><xsl:text>);</xsl:text>
								</xsl:attribute>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:if>
					<xsl:attribute name="id">fld_<xsl:value-of select="$thisid"/></xsl:attribute>
					<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
					<xsl:for-each select="subobjs/subwf_obj">
						<option>
							<xsl:attribute name="id">fld_<xsl:value-of select="$thisid"/></xsl:attribute>
							<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
							<xsl:if test="value=$thispreval">
								<xsl:attribute name="selected"></xsl:attribute>
							</xsl:if>
							<xsl:value-of select="prompt"/>
						</option>
					</xsl:for-each>
				</select>
				<input type="Text">
					<xsl:call-template name="input_entry"/>
					<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
					<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
					<xsl:attribute name="size"><xsl:value-of select="length"/></xsl:attribute>
					<xsl:attribute name="value"><xsl:value-of select="$thissufval"/></xsl:attribute>
				</input>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
		
	<xsl:template name="SelectDropMulti">
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:call-template name="input_hidden">
			<xsl:with-param name="nme"><xsl:value-of select="@name"/></xsl:with-param>
			<xsl:with-param name="id"><xsl:value-of select="@id"/></xsl:with-param>
		</xsl:call-template>
		<table>
			<xsl:for-each select="subobjs/subwf_obj">
				<tr>
					<td>
						<select>
							<xsl:call-template name="select_class"/>
							<xsl:attribute name="id">fld_<xsl:value-of select="$thisid"/>_<xsl:value-of select="@value"/></xsl:attribute>
							<xsl:attribute name="name"><xsl:value-of select="$thisname"/>_<xsl:value-of select="value"/></xsl:attribute>
							<option value="1">1</option>
							<option value="2">2</option>
							<option value="3">3</option>
							<option value="4">4</option>
							<option value="5">5</option>
							<option value="6">6</option>
						</select>
					</td>
					<td><xsl:value-of select="prompt"/></td>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:template>
	
	<xsl:template name="SelectExpiry">
		<xsl:call-template name="input_hidden">
			<xsl:with-param name="nme"><xsl:value-of select="@name"/></xsl:with-param>
			<xsl:with-param name="id"><xsl:value-of select="@id"/></xsl:with-param>
		</xsl:call-template>
		<select onchange="calc_wf_expiry(this)">
			<xsl:call-template name="select_class"/>
			<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
			<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
				<xsl:for-each select="subobjs[@name='month']/subwf_obj">
					<option>
						<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
						<xsl:value-of select="prompt"/>
					</option>
				</xsl:for-each>
		</select>
		<select onchange="calc_wf_expiry(this)">
			<xsl:call-template name="select_class"/>
			<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
			<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
				<xsl:for-each select="subobjs[@name='year']/subwf_obj">
					<option>
						<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
						<xsl:value-of select="prompt"/>
					</option>
				</xsl:for-each>
		</select>
	</xsl:template>

	<xsl:template name="Check">
		<table>
			<colgroup>
				<col class="check"/>
				<col/>
			</colgroup>
			<tr>
				<td>
					<input type="checkbox">
						<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
						<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
						<xsl:if test="parent::*[name()='confirms']">
							<xsl:attribute name="style">display:none;</xsl:attribute>
							<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
						</xsl:if>
					</input>
				</td>
				<td align="left" class="fm-chk-pr"><xsl:apply-templates select="prompt"/></td>
			</tr>
		</table>
	</xsl:template>
	
	<xsl:template name="CheckAgree">
		<table>
			<colgroup>
				<col/>
				<col/>
			</colgroup>
			<tr>
				<td width="4">
					<xsl:attribute name="class">
						<xsl:choose>
							<xsl:when test="parent::*[name()='confirms']">check</xsl:when>
							<xsl:otherwise>fm-chk</xsl:otherwise>
						</xsl:choose>
					
					</xsl:attribute>
					<input type="checkbox">
						<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
						<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
						<xsl:if test="parent::*[name()='confirms']">
							<xsl:attribute name="style">display:none;</xsl:attribute>
							<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
						</xsl:if>
					</input>
				</td>
				<td class="fm-chk-pr"><xsl:apply-templates select="prompt"/></td>
			</tr>
		</table>
	</xsl:template>

	<xsl:template name="CheckSelect">
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thisval" select="value"/>
		<xsl:choose>
			<xsl:when test="@input='readonly' or parent::*[name()='confirms']">
				<div class="fm-chk-sel"><xsl:value-of select="subobjs/subwf_obj[value=$thisval]/prompt"/></div>
			</xsl:when>
			<xsl:otherwise>
				<table>
					<colgroup>
						<col/>
						<col/>
					</colgroup>
					<tr>
						<td width="4" class="fm-chk">
							<input type="Checkbox" onclick="javascript:x_form.SelectCheck(this, true)">
								<xsl:attribute name="id">fld_<xsl:value-of select="$thisid"/>_check</xsl:attribute>
								<xsl:attribute name="name"><xsl:value-of select="$thisname"/>_check</xsl:attribute>
							</input>
						</td>
						<td align="left" class="fm-chk-sl">
							<select onchange="javascript:x_form.SelectCheck(this, false)"> <!--onchange="calc_wf_chkval(this)"-->
								<xsl:call-template name="select_class"/>
								<xsl:attribute name="id">fld_<xsl:value-of select="$thisid"/></xsl:attribute>
								<xsl:attribute name="name"><xsl:value-of select="$thisname"/></xsl:attribute>
								<xsl:for-each select="subobjs/subwf_obj">
									<option>
										<xsl:attribute name="id">fld_<xsl:value-of select="$thisid"/></xsl:attribute>
										<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
										<xsl:value-of select="prompt"/>
									</option>
								</xsl:for-each>
							</select>
						</td>
					</tr>
				</table>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="CheckMulti">
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thisval" select="value"/>		
		<xsl:call-template name="input_hidden">
			<xsl:with-param name="nme"><xsl:value-of select='@name'/></xsl:with-param>
			<xsl:with-param name="id"><xsl:value-of select='@id'/></xsl:with-param>
		</xsl:call-template>
		<table>
			<colgroup>
				<col/>
				<col/>
			</colgroup>
			<xsl:for-each select="subobjs/subwf_obj">
				<tr>
					<td width="4" class="fm-chk">
						<input type="Checkbox">
							<xsl:attribute name="id">fld_<xsl:value-of select="$thisid"/></xsl:attribute>
							<xsl:attribute name="name"><xsl:value-of select="$thisname"/></xsl:attribute>
							<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
						</input>
					</td>
					<td align="left" class="fm-pr">
						<xsl:value-of select="prompt"/>
						<xsl:if test="fld">
							<xsl:call-template name='nobrspace'/>
							<xsl:value-of select="fld/prompt"/><br/><br/>
							<input type="Text">
								<xsl:call-template name="input_entry"/>
								<xsl:attribute name="name"><xsl:value-of select="fld/@name"/></xsl:attribute>
								<xsl:attribute name="value"><xsl:value-of select="fld/value"/></xsl:attribute>
							</input>
						</xsl:if>
					</td>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:template>

	<xsl:template name="Checks">
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thisval" select="value"/>
		<table>
			<colgroup>
				<col/>
				<col/>
			</colgroup>
			<input type="hidden">
				<xsl:attribute name='name'><xsl:value-of select='$thisname'/></xsl:attribute>
				<xsl:attribute name='id'>fld_<xsl:value-of select='$thisid'/></xsl:attribute>
			</input>
			<xsl:choose>
				<xsl:when test="@input='readonly' or parent::*[name()='confirms']">
					<tr>
						<td colspan="2">
							<input type="Text" size="20">
								<xsl:call-template name="input_entry"/>
								<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
								<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
								<xsl:attribute name="value">
									<xsl:for-each select='subobjs/subwf_obj'>
										<xsl:if test="ancestor::fld/value = ./value">
											<xsl:apply-templates select="./prompt"/>
										</xsl:if>
									</xsl:for-each>
								</xsl:attribute>
							</input>
						</td>
					</tr>
				</xsl:when>
				<xsl:otherwise>
					<xsl:for-each select='subobjs/subwf_obj'>
						<tr>
							<td width="4" class="fm-chk">
								<input type="Checkbox">
									<xsl:attribute name='id'>fld_<xsl:value-of select='$thisid'/></xsl:attribute>
									<xsl:attribute name='name'><xsl:value-of select='$thisname'/>_<xsl:value-of select='value'/></xsl:attribute>
											<xsl:if test="ancestor::fld/value = ./value">
												<xsl:attribute name="checked">checked</xsl:attribute>
											</xsl:if>										
									<xsl:attribute name="onclick">
										<xsl:text>javascript:x_form.SetCheck('fld_</xsl:text><xsl:value-of select='$thisid'/><xsl:text>', false);</xsl:text>
										<xsl:if test="update">
											<xsl:text>x_form.</xsl:text><xsl:value-of select="update/@function"/><xsl:text>(this, </xsl:text><xsl:value-of select="update/@fld"/><xsl:text>, '</xsl:text><xsl:value-of select="update/value"/><xsl:text>');</xsl:text>
										</xsl:if>
									</xsl:attribute>
								</input>
							</td>
							<td align="left" class="fm-chk-pr"><xsl:apply-templates select="prompt" mode="tabs"/></td>
						</tr>
					</xsl:for-each>
				</xsl:otherwise>
			</xsl:choose>	
		</table>
	</xsl:template>
	
	<!-- cloned, simplified and modified from Checks: 
	-->
	<xsl:template name="CheckList">
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thisval" select="value"/>
		<xsl:choose>
			<xsl:when test="@input='readonly' or parent::*[name()='confirms']">
				<input type="Text">
					<xsl:call-template name="input_entry"/>
					<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
					<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
					<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
				</input>
			</xsl:when>
			<xsl:otherwise>
				<table>
					<colgroup>
						<col/>
						<col/>
					</colgroup>
					<input type="hidden">
						<xsl:attribute name='name'><xsl:value-of select='$thisname'/></xsl:attribute>
						<xsl:attribute name='id'>fld_<xsl:value-of select='$thisid'/></xsl:attribute>
					</input>
					<xsl:for-each select='subobjs/subwf_obj'>
						<tr>
							<td width="4" class="fm-chk">
								<input type="Checkbox">
									<xsl:attribute name='id'>fld_<xsl:value-of select='$thisid'/></xsl:attribute>
									<xsl:attribute name='name'><xsl:value-of select='$thisname'/>_<xsl:value-of select='value'/></xsl:attribute>
									<xsl:if test="contains(ancestor::fld/value, ./value)">
										<xsl:attribute name="checked">checked</xsl:attribute>
									</xsl:if>										
									<xsl:attribute name="onclick">
										<xsl:text>javascript:x_form.SetCheck('fld_</xsl:text><xsl:value-of select='$thisid'/><xsl:text>', true);</xsl:text>
									</xsl:attribute>
									<xsl:attribute name="value"><xsl:value-of select='value'/></xsl:attribute>
								</input>
							</td>
							<td align="left" class="fm-chk-pr"><xsl:apply-templates select="prompt" mode="tabs"/></td>
						</tr>
					</xsl:for-each>
				</table>
			</xsl:otherwise>
		</xsl:choose>	
	</xsl:template>

	<xsl:template name="CheckTri">
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:choose>
			<xsl:when test="@input='readonly' or parent::*[name()='confirms']">
				<xsl:call-template name="InputText"/>
			</xsl:when>
			<xsl:otherwise>
				<table>
					<colgroup>
						<col/>
						<col/>
					</colgroup>
					<input type="hidden">
						<xsl:attribute name='name'><xsl:value-of select='$thisname'/></xsl:attribute>
						<xsl:attribute name='id'>fld_<xsl:value-of select='$thisid'/></xsl:attribute>
					</input>
					<tr>
						<td width="4" class="fm-chk">
							<input type="Checkbox">
								<xsl:attribute name='id'>fld_<xsl:value-of select='$thisid'/></xsl:attribute>
								<xsl:attribute name='name'><xsl:value-of select='$thisname'/>_<xsl:value-of select='value'/></xsl:attribute>
								<xsl:attribute name="onclick">
									<xsl:text>javascript:x_form.SetCheck('fld_</xsl:text><xsl:value-of select='$thisid'/><xsl:text>', true);</xsl:text>
									<xsl:if test="update">
										<xsl:text>x_form.</xsl:text><xsl:value-of select="update/@function"/><xsl:text>(this, </xsl:text><xsl:value-of select="update/@fld"/><xsl:text>, '</xsl:text><xsl:value-of select="value"/><xsl:text>');</xsl:text>
									</xsl:if>
								</xsl:attribute>
								<xsl:attribute name='value'><xsl:text>R </xsl:text><xsl:value-of select='value'/></xsl:attribute>
							</input>
						</td>
						<td align="left" class="fm-chk-pr">
							<xsl:apply-templates select='update/prefix'/><xsl:value-of select="value"/><xsl:apply-templates select='update/suffix'/>
						</td>
					</tr>
				</table>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="prefix">
		<xsl:apply-templates />
	</xsl:template>

	<xsl:template match="suffix">
		<xsl:apply-templates />
	</xsl:template>

	<xsl:template name="InputButton">
		<input type="button" class="fm-btn">
			<xsl:attribute name="id">fld_<xsl:value-of select="@id"/></xsl:attribute>
			<xsl:attribute name="width"><xsl:value-of select="length"/></xsl:attribute>
			<xsl:attribute name="value"><xsl:value-of select="prompt"/></xsl:attribute>
			<xsl:attribute name="onClick">
				<xsl:choose>
					<xsl:when test="@type='fld_btn_link'">
						<xsl:text>javascript:x_page.Link('</xsl:text><xsl:value-of select="value"/><xsl:text>')</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>javascript:x_page.Popup('</xsl:text><xsl:value-of select="$BaseLinkUrl"/><xsl:value-of select="value"/><xsl:text>')</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
		</input>
	</xsl:template>
	
	<xsl:template name="InputLink">
		<a>
			<xsl:attribute name="href">
				<xsl:choose>
					<xsl:when test="@type='fld_link'">
						<xsl:text>javascript:x_page.Link('</xsl:text><xsl:value-of select="value"/><xsl:text>')</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>javascript:x_page.Popup('</xsl:text><xsl:value-of select="$BaseLinkUrl"/><xsl:value-of select="value"/><xsl:text>')</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
			<xsl:text>Click here</xsl:text>
		</a>
	</xsl:template>
	
<!--=========================
	Utility templates section
	========================= -->
	
	<xsl:template name="input_entry">
		<xsl:param name="wantsize">yes</xsl:param>
		<xsl:attribute name="class">
			<xsl:choose>
				<xsl:when test="(@input='readonly' or @input='readonly_grp' or parent::*[name()='confirms']) and not(@input='total') and not(parent::*/@component='xed')"><xsl:text>ro-inp-man</xsl:text></xsl:when>
				<xsl:when test="(@input='readonly' or @input='readonly_grp' or parent::*[name()='confirms']) and parent::*/@component='xed'"><xsl:text>ro_xed-inp-man</xsl:text></xsl:when>
				<xsl:when test="@input='highlight' or @input='highlight_grp'"><xsl:text>ro-inp-opt</xsl:text></xsl:when>
				<xsl:when test="parent::*[name()='confirms'] and not(@input='total')"><xsl:text>ro-inp</xsl:text></xsl:when>
				<xsl:when test="parent::*[name()='logon']"><xsl:text>ri-inp</xsl:text></xsl:when>
				<xsl:when test="parent::*[name()='relinf']"><xsl:text>ri-inp</xsl:text></xsl:when>
				<xsl:when test="@input='total'"><xsl:text>ro-inp-tot</xsl:text></xsl:when>
				<xsl:otherwise>
					<xsl:choose>
						<xsl:when test="@type='fld_info'"><xsl:text>txt-inp</xsl:text></xsl:when>
						<xsl:when test="mandatory='Y' and not(@type='fld_agree')"><xsl:text>man-inp</xsl:text></xsl:when>
						<xsl:when test="@type='fld_checks' or @type='fld_agree'"><xsl:text></xsl:text></xsl:when>
						<xsl:otherwise><xsl:text>opt-inp</xsl:text></xsl:otherwise>
					</xsl:choose>
				</xsl:otherwise>
			</xsl:choose>
			<xsl:if test="$wantsize='yes'">
				<xsl:variable name="len" select="number(length)"/>
				<xsl:choose>
					<xsl:when test="width='rel'"><xsl:text></xsl:text></xsl:when>
					<xsl:when test="$len &lt; 9 or width='tiny'"><xsl:text> i-t</xsl:text></xsl:when>
					<xsl:when test="$len &lt; 15 or width='small'"><xsl:text> i-s</xsl:text></xsl:when>
					<xsl:when test="$len &lt; 21 or width='medium'"><xsl:text> i-m</xsl:text></xsl:when>
					<xsl:when test="$len &gt; 40 or width='xlarge'"><xsl:text> i-x</xsl:text></xsl:when>
					<xsl:otherwise><xsl:text> i-l</xsl:text></xsl:otherwise>
				</xsl:choose>
			</xsl:if>			
			<xsl:if test="@type='fld_info' or @type='fld_sms'">
				<xsl:choose>
					<xsl:when test="height='tiny'"><xsl:text> h-t</xsl:text></xsl:when>
					<xsl:when test="height='small'"><xsl:text> h-s</xsl:text></xsl:when>
					<xsl:when test="height='medium'"><xsl:text> h-m</xsl:text></xsl:when>
					<xsl:when test="height='large'"><xsl:text> h-l</xsl:text></xsl:when>
					<xsl:when test="height='xlarge'"><xsl:text> h-x</xsl:text></xsl:when>
					<xsl:otherwise></xsl:otherwise>
				</xsl:choose>
			</xsl:if>			
		</xsl:attribute>
		<xsl:if test="@input='readonly' or @input='highlight' or parent::*[name()='confirms']">
			<xsl:attribute name='readonly'><xsl:text>true</xsl:text></xsl:attribute>
		</xsl:if>
		<xsl:if test="@click='select'">
			<xsl:attribute name="onfocus">javascript:this.select()</xsl:attribute>
		</xsl:if>
	</xsl:template>
	
	<xsl:template name="input_hidden">
 		<xsl:param name="nme"/>
 		<xsl:param name="id"/>
		<!-- don't do any hidden fields for now...
		<input type="hidden">
			<xsl:attribute name='name'><xsl:value-of select='$name'/></xsl:attribute>
			<xsl:attribute name='id'>fld_<xsl:value-of select='$id'/></xsl:attribute>
			<xsl:attribute name='value'><xsl:value-of select='value'/></xsl:attribute>
		</input>
		-->
	</xsl:template>

	<xsl:template name="input_calc">
 		<xsl:param name="type"/> <!-- either 'text' or 'radio' -->
 		<xsl:param name="nme"/>
 		<xsl:param name="id"/>
 		<xsl:param name="length"/>
 		<xsl:param name="value"/>
		<xsl:param name="visibility"/>
		<xsl:param name="selected"/>
		<xsl:param name="showprompt"/>
		<xsl:param name="hideprompt"/>
		<input> 
			<xsl:attribute name='type'><xsl:value-of select='$type'/></xsl:attribute>
			<xsl:attribute name='id'>fld_<xsl:value-of select='$id'/></xsl:attribute>
			<xsl:attribute name='name'><xsl:value-of select='$nme'/></xsl:attribute>
			<xsl:if test="string-length($showprompt)&gt;0">
				<xsl:attribute name="onclick">document.all['<xsl:value-of select="$showprompt"/>'][0].style.display='block';</xsl:attribute>
			</xsl:if>
			<xsl:if test="string-length($hideprompt)&gt;0">
				<xsl:attribute name="onclick">document.all['<xsl:value-of select="$hideprompt"/>'][0].style.display='none';document.all['<xsl:value-of select="$hideprompt"/>'][1].value='';</xsl:attribute>
			</xsl:if>
			<xsl:choose>
				<xsl:when test="$type='radio'">
					<xsl:attribute name='value'><xsl:value-of select='value'/></xsl:attribute>
					<xsl:attribute name="class">fm-rad</xsl:attribute>
					<xsl:if test="value=$value">
						<xsl:attribute name='checked'></xsl:attribute>
					</xsl:if>
				</xsl:when>
				<xsl:otherwise>
					<xsl:attribute name='size'><xsl:value-of select='$length'/></xsl:attribute>
					<xsl:attribute name='value'><xsl:value-of select='$value'/></xsl:attribute>
				</xsl:otherwise>
			</xsl:choose>
			<xsl:if test="$visibility !=''">
				<xsl:call-template name="set_visibility_onclick">
					<xsl:with-param name="visibilityFld"><xsl:value-of select='$visibility'/></xsl:with-param>
				</xsl:call-template>
			</xsl:if>
			<xsl:if test="$selected = 'yes'"><xsl:attribute name='checked'/></xsl:if>
		</input>
	</xsl:template>

	<xsl:template name="set_visibility_onclick">
		<xsl:param name="visibilityFld"/>
		<xsl:attribute name='onClick'>
			<xsl:text>javascript:x_form.SetVisibility(</xsl:text>
			<xsl:choose>
				<xsl:when test="@visible='no'"><xsl:text>false</xsl:text></xsl:when>
				<xsl:otherwise><xsl:text>true</xsl:text></xsl:otherwise>
			</xsl:choose>
			<xsl:text>, '</xsl:text>
			<xsl:value-of select='$visibilityFld'/><xsl:text>', 'fld_</xsl:text>
			<xsl:value-of select="following::fld[@name=$visibilityFld]/@id"/>
			<xsl:text>', </xsl:text>
			<xsl:choose>
				<xsl:when test="parent::*/@collapse">true</xsl:when>
				<xsl:otherwise>false</xsl:otherwise>
			</xsl:choose>
			<xsl:text>);</xsl:text>
		</xsl:attribute>
		<!--
		<xsl:attribute name='onClick'>
			<xsl:choose>
				<xsl:when test="@visible='no'"><xsl:text>javascript:x_form.SetHidden('</xsl:text></xsl:when>
				<xsl:otherwise><xsl:text>javascript:x_form.SetVisibile('</xsl:text></xsl:otherwise>
			</xsl:choose>
			<xsl:value-of select='$visibilityFld'/><xsl:text>', </xsl:text>
		</xsl:attribute>
		-->
	</xsl:template>

	<xsl:template name="select_date">
		<xsl:param name="thisid" />
		<xsl:param name="which" />
		<xsl:param name="thisval" />
		<xsl:param name="thissub" />
		<select>
			<xsl:call-template name="select_class"/>
			<xsl:attribute name="name"><xsl:value-of select="@name"/>_<xsl:value-of select="$which"/></xsl:attribute>
			<xsl:attribute name="id">
				<xsl:text>fld_</xsl:text>
				<xsl:choose>
					<xsl:when test="$thissub='no'"><xsl:value-of select="@id"/></xsl:when>
					<xsl:otherwise><xsl:value-of select="$thisid"/></xsl:otherwise>
				</xsl:choose>
				<xsl:text>_</xsl:text><xsl:value-of select="$which"/>
			</xsl:attribute>
			<xsl:if test="$thissub='no'">
				<xsl:attribute name="onchange">javascript:x_form.CalcDate(fld_<xsl:value-of select="$thisid"/>);</xsl:attribute>
			</xsl:if>
			<!-- add the year options from the subobjs element -->
			<xsl:for-each select="subobjs[@name=$which]/subwf_obj">
				<option>
					<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
					<xsl:if test="value=$thisval">
						<xsl:attribute name="selected">true</xsl:attribute>
					</xsl:if>
					<xsl:value-of select="prompt"/>
				</option>
			</xsl:for-each>
		</select>
	</xsl:template>
		
	<xsl:template name="FormButtons">
		<xsl:param name="which"/>
		<xsl:param name="docref"/>
		<xsl:param name="thisfrm"/>
		<xsl:param name="islinks"/>
		
		<xsl:if test="$device='' or $device='screen'">
			<div>
				<xsl:attribute name="id">
					<xsl:choose>
						<xsl:when test="@buttonstyle">fm-btn-<xsl:value-of select="@buttonstyle"/></xsl:when>
						<xsl:when test="$islinks!='yes' or not($islinks)">fm-btn</xsl:when>
						<xsl:otherwise>fm-btn-lnks</xsl:otherwise>
					</xsl:choose>
				</xsl:attribute>
	
				<xsl:choose>
					<xsl:when test="$which = 'launch'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Launch</xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'go'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Go</xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'next'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Next</xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
							<xsl:with-param name="important">yes</xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'update'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Update</xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'back'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Back</xsl:with-param>
							<xsl:with-param name="type">back</xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'back-next'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Back</xsl:with-param>
							<xsl:with-param name="type">back</xsl:with-param>
						</xsl:call-template>
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Next</xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'back-refresh'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Back</xsl:with-param>
							<xsl:with-param name="type">back</xsl:with-param>
						</xsl:call-template>
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Try Again</xsl:with-param>
							<xsl:with-param name="type">refresh</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'back-submit'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Back</xsl:with-param>
							<xsl:with-param name="type">back</xsl:with-param>
						</xsl:call-template>
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Submit</xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'down-next'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Download</xsl:with-param>
							<xsl:with-param name="type">down</xsl:with-param>
							<xsl:with-param name="document"><xsl:value-of select="$docref"/></xsl:with-param>
						</xsl:call-template>
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Next</xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'down-logon-next'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Download</xsl:with-param>
							<xsl:with-param name="type">down</xsl:with-param>
							<xsl:with-param name="document"><xsl:value-of select="$docref"/></xsl:with-param>
						</xsl:call-template>
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Next</xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Logon</xsl:with-param>
							<xsl:with-param name="type">logon</xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'logon-next'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Next</xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Logon</xsl:with-param>
							<xsl:with-param name="type">logon</xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'confirm'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Back</xsl:with-param>
							<xsl:with-param name="type">back</xsl:with-param>
						</xsl:call-template>
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Submit</xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'cancel-email'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Cancel</xsl:with-param>
							<xsl:with-param name="type">back</xsl:with-param>
						</xsl:call-template>
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">E-mail</xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'apply'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Back</xsl:with-param>
							<xsl:with-param name="type">back</xsl:with-param>
						</xsl:call-template>
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Apply</xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'submit'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Submit</xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'download'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Download</xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'custom'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label"><xsl:value-of select="@buttonlabel"/></xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'print'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Print</xsl:with-param>
							<xsl:with-param name="type">print</xsl:with-param>
						</xsl:call-template>
					</xsl:when>				
					<xsl:when test="$which = 'delete-confirm'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Cancel</xsl:with-param>
							<xsl:with-param name="type">back</xsl:with-param>
						</xsl:call-template>
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Delete</xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<!-- HP_Dev: Added for 'change-next' -->
					<xsl:when test="$which = 'custom-next'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label"><xsl:value-of select="custom/@buttonlabel"/></xsl:with-param>
							<xsl:with-param name="type">custom</xsl:with-param>
						</xsl:call-template>
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Next</xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="$which = 'close'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Close window</xsl:with-param>
							<xsl:with-param name="type">close</xsl:with-param>
						</xsl:call-template>
					</xsl:when>				
					<xsl:when test="$which = 'close-submit'">
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Close window</xsl:with-param>
							<xsl:with-param name="type">close</xsl:with-param>
						</xsl:call-template>
						<xsl:call-template name="FormButton">
							<xsl:with-param name="label">Submit</xsl:with-param>
							<xsl:with-param name="type">next</xsl:with-param>
							<xsl:with-param name="formname"><xsl:value-of select="$thisfrm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:otherwise> <!-- no button -->
						<xsl:call-template name="nobrspace"/>
					</xsl:otherwise>
				</xsl:choose>
			</div>
		</xsl:if>
	</xsl:template>
	
	<xsl:template name="FormButton">
		<xsl:param name="label"/>
		<xsl:param name="type"/>
		<xsl:param name="formname"/>
		<xsl:param name="document"/>
		<xsl:param name="important"/>
		<xsl:param name="jumpmenu"/>
		<xsl:param name="onclick"/>
		
		<!--
		Label: <xsl:value-of select="$label"/><br/>
		Type: <xsl:value-of select="$type"/><br/>
		Formname: <xsl:value-of select="$formname"/><br/>
		Document: <xsl:value-of select="$document"/><br/>
		Important: <xsl:value-of select="$important"/><br/>
		-->

		<input type="Button">
			<xsl:attribute name="class">
				<xsl:choose>
					<xsl:when test="@buttonstyle">fm-btn-<xsl:value-of select="@buttonstyle"/></xsl:when>
					<xsl:when test="$jumpmenu='yes'">rprt-btn aed</xsl:when>
					<xsl:when test="@component='xed'">fm_xed_btn</xsl:when>
					<xsl:when test="@component='xed'">fm_xed_btn</xsl:when>
					<xsl:otherwise>fm-btn</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
			<xsl:attribute name="value"><xsl:value-of select="$label"/></xsl:attribute>
			<xsl:attribute name="onClick">
				<xsl:choose>
					<xsl:when test="$type='next'">
						<xsl:text>javascript:</xsl:text>
						<xsl:choose>
							<xsl:when test="validation/@frm_obj"><xsl:value-of select="validation/@frm_obj"/></xsl:when>
							<xsl:otherwise><xsl:text>x_form</xsl:text></xsl:otherwise>
						</xsl:choose>
						<xsl:text>.Check('</xsl:text><xsl:value-of select='$formname'/>
						<xsl:text>','</xsl:text>
						<xsl:choose>
							<xsl:when test="@type"><xsl:value-of select="@type"/></xsl:when>
							<xsl:otherwise><xsl:text>valid</xsl:text></xsl:otherwise>
						</xsl:choose>
						<xsl:text>',</xsl:text>
						<xsl:choose>
							<xsl:when test="validation">validateForm</xsl:when>
							<xsl:otherwise>null</xsl:otherwise>
						</xsl:choose>
						<xsl:text>)</xsl:text>
					</xsl:when>
					<xsl:when test="$type='back'">javascript:x_form.Previous()</xsl:when>
					<xsl:when test="$type='print'">javascript:x_page.PopOut('ver5_print')</xsl:when>
					<xsl:when test="$type='refresh'">javascript:window.location.href = unescape(window.location.href);</xsl:when>
					<xsl:when test="$type='logon'">
						<xsl:text>javascript:x_page.GoUrl('</xsl:text>
						<xsl:choose>
							<xsl:when test="logon/@page='yes'">
								<xsl:call-template name="simple-link">
									<xsl:with-param name="link">
										<xsl:value-of select="logon/@link"/>
									</xsl:with-param>
								</xsl:call-template>
							</xsl:when>
							<xsl:otherwise>
								<xsl:call-template name="url">
									<xsl:with-param name="link">
										<xsl:value-of select="logon/@link"/>
									</xsl:with-param>
								</xsl:call-template>
							</xsl:otherwise>
						</xsl:choose>
						<xsl:text>');</xsl:text>
					</xsl:when>
					<xsl:when test="$type='submit'">
						<xsl:text>javascript:</xsl:text><xsl:value-of select='$formname'/><xsl:text>.submit()</xsl:text>
					</xsl:when>
					<xsl:when test="$type='custom'">
						<xsl:choose>
							<xsl:when test="custom">
								<xsl:text>javascript:x_page.GoUrl('</xsl:text>
								<xsl:call-template name="simple-link">
									<xsl:with-param name="link">
										<xsl:value-of select="custom/@link"/>
									</xsl:with-param>
								</xsl:call-template>
								<xsl:text>');</xsl:text>
							</xsl:when>
							<xsl:otherwise>
								<xsl:text>javascript:</xsl:text><xsl:value-of select='$formname'/><xsl:text>.submit()</xsl:text>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:when test="$type='onclick'"><xsl:value-of select="$onclick"/></xsl:when>
					<xsl:when test="$type='close'">javascript:window.close();</xsl:when>
				</xsl:choose>
			</xsl:attribute>
		</input>
	</xsl:template>

	<xsl:template name="select_class">
		<xsl:param name="mandatory"/>
		<xsl:variable name="len" select="number(length)"/>
		<xsl:attribute name="class">
			<xsl:choose>
				<xsl:when test="$mandatory='N'">
					<xsl:choose>
						<xsl:when test="width='rel'"><xsl:text></xsl:text></xsl:when>
						<xsl:when test="$len &lt; 9 or width='tiny'"><xsl:text>s-t s-opt</xsl:text></xsl:when>
						<xsl:when test="$len &lt; 15 or width='small'"><xsl:text>s-s s-opt</xsl:text></xsl:when>
						<xsl:when test="$len &lt; 21 or width='medium'"><xsl:text>s-m s-opt</xsl:text></xsl:when>
						<xsl:when test="$len &gt; 40 or width='xlarge'"><xsl:text>s-x s-opt</xsl:text></xsl:when>
						<xsl:otherwise><xsl:text>s-l s-opt</xsl:text></xsl:otherwise><!-- 'large' is default -->
					</xsl:choose>
				</xsl:when>
				<xsl:otherwise>
					<xsl:choose>
						<xsl:when test="width='rel'"><xsl:text></xsl:text></xsl:when>
						<xsl:when test="$len &lt; 9 or width='tiny'"><xsl:text>s-t</xsl:text></xsl:when>
						<xsl:when test="$len &lt; 15 or width='small'"><xsl:text>s-s</xsl:text></xsl:when>
						<xsl:when test="$len &lt; 21 or width='medium'"><xsl:text>s-m</xsl:text></xsl:when>
						<xsl:when test="$len &gt; 40 or width='xlarge'"><xsl:text>s-x</xsl:text></xsl:when>
						<xsl:otherwise><xsl:text>s-l</xsl:text></xsl:otherwise><!-- 'large' is default -->
					</xsl:choose>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:attribute>
	</xsl:template>
		
	<xsl:template name="TextEditor">
		<table>
			<tr>
				<td class="xed_tool_cell"><div id="divToolbar" class="xed_tool"></div></td>
			</tr>
			<tr>
				<td class="xed_obj_cell"><xsl:call-template name="TextEditorObject"/></td>
			</tr>
		</table>
	</xsl:template>
	
	<xsl:template name="TextEditorObject">
		<object id="objContent" class="xed_text" classid="clsid:2D360201-FFF5-11D1-8D03-00A0C959BC0A" viewastext="true">
			<param name="ActivateApplets" value="0" />
			<param name="ActivateActiveXControls" value="0" />
			<param name="ActivateDTCs" value="1" />
			<param name="ShowDetails" value="0" />
			<param name="ShowBorders" value="0" />
			<param name="Appearance" value="1" />
			<param name="Scrollbars" value="1" />
			<param name="ScrollbarAppearance" value="1" />
			<param name="SourceCodePreservation" value="1" />
			<param name="AbsoluteDropMode" value="0" />
			<param name="SnapToGrid" value="0" />
			<param name="SnapToGridX" value="50" />
			<param name="SnapToGridY" value="50" />
			<param name="UseDivOnCarriageReturn" value="1" />
		</object>
		<xsl:call-template name="TextEditorCOM"/>
	</xsl:template>
	
	<xsl:template name="TextEditorCOM">
		<script language="javascript" src="scripts/ver5/xed/x_all.js"></script>
		<script language="javascript" src="scripts/ver5/xed/dhtmled.js"></script>
		<script language="javascript" src="scripts/ver5/xed/x_itext.js"></script>
		<script language="javascript" src="scripts/ver5/xed/x_editor.js"></script>
		<script language="javascript" src="scripts/ver5/xed/x_config.js"></script>
		<script language="javascript" src="scripts/ver5/xed/x_toolbar.js"></script>
		<script language="javascript" src="scripts/ver5/xed/x_xhtml.js"></script>
		<script language="javascript" src="scripts/ver5/xed/x_contextmenu.js"></script>
		<script language="javascript" src="scripts/ver5/xed/x_lang.js"></script>
		<script language="javascript" src="scripts/ver5/xed/x_instance.js"></script>
		<script language="javascript" event="DocumentComplete" for="objContent">	
			x_config.SetToolbar('umlungu');
			<xsl:text>x_editor.Init('</xsl:text>
			<xsl:value-of select="@id"/>
			<xsl:text>');</xsl:text>
		</script>
		<script language="javascript" event="onerror(msg, url, line)" for="window">
			x_editor.Debug(msg, 'line', line);
		</script>
		<script language="javascript" event="DisplayChanged" for="objContent">x_editor.FireEvent('onEditing');</script>
		<script language="javascript" event="ShowContextMenu" for="objContent">x_contextMenu.Show();</script>
		<script language="javascript" event="ContextMenuAction(itemIndex)" for="objContent">x_contextMenu.Action(itemIndex);</script>
		<script language="JavaScript">document.x_form.onkeypress = x_onFormPress;</script>
	</xsl:template>
	
	<xsl:template name="x_editor">
		<xsl:variable name="thisid">fld_<xsl:value-of select='@id'/></xsl:variable>
		<!-- Constants -->
		<script language="javascript" src="scripts/ver5/xed/dhtmled.js"></script>
		<script language="javascript" src="scripts/ver5/xed/x_itext.js"></script>
		<!-- Includes -->
		<script language="javascript" src="scripts/ver5/xed/x_editor.js"></script>
		<script language="javascript" src="scripts/ver5/xed/x_config.js"></script>
		<script language="javascript" src="scripts/ver5/xed/x_toolbar.js"></script>
		<script language="javascript" src="scripts/ver5/xed/x_xhtml.js"></script>
		<script language="javascript" src="scripts/ver5/xed/x_contextmenu.js"></script>
		<script language="javascript" src="scripts/ver5/xed/x_lang.js"></script>
		<!-- Instances and arrays -->
		<script language="javascript" src="scripts/ver5/xed/x_instance.js"></script>
		<!-- DEC Events -->
		<script language="javascript" event="DocumentComplete"	for="objContent">
			<xsl:choose>
				<xsl:when test="parent::*/xedstyle/@val='nmportal-img'">
					<xsl:text>x_config.SetStyle('/styles/ver5/x_editor_img.css');</xsl:text>
				</xsl:when>
				<xsl:when test="parent::*/xedstyle/@val='nmportal-faq'">
					<xsl:text>x_config.SetStyle('/styles/ver5/x_editor_faq.css');</xsl:text>
				</xsl:when>
				<xsl:when test="parent::*/xedstyle/@val='nmintranet-img'">
					<xsl:text>x_config.SetStyle('/styles/ver5/x_editor_aboutus.css');</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>x_config.SetStyle('/styles/ver5/x_editor.css');</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
			<xsl:text>x_config.SetToolbar('</xsl:text>
			<xsl:choose>
				<xsl:when test="parent::*/xedstyle"><xsl:value-of select="parent::*/xedstyle/@val"/></xsl:when>
				<xsl:otherwise>nmportal</xsl:otherwise>
			</xsl:choose>
			<xsl:text>');</xsl:text>
			<xsl:text>x_editor.Init('</xsl:text><xsl:value-of select="$thisid"/><xsl:text>');</xsl:text>
		</script>
		<script language="javascript" event="onerror(msg, url, line)"		for="window">x_editor.Debug(msg, 'line', line);</script>
		<script language="javascript" event="DisplayChanged"				for="objContent">x_editor.FireEvent('onEditing');</script>
		<script language="javascript" event="ShowContextMenu"				for="objContent">x_contextMenu.Show();</script>
		<script language="javascript" event="ContextMenuAction(itemIndex)"	for="objContent">x_contextMenu.Action(itemIndex);</script>
		
		<table>
			<tr>
				<td class="xed_tool_cell"><div id="divToolbar" class="xed_tool"></div></td>
			</tr>
			<tr>
				<td class="xed_obj_cell"><xsl:call-template name="x_editorObject"/></td>
			</tr>
			<tr id="trSource" style="DISPLAY: none">
				<td>
					<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
						<tr>
							<td><div id="divToolbarSource"></div></td>
						</tr>
						<tr height="100%">
							<td><textarea class="xed_text" id="txtSource"></textarea></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		<div id="divTemp" style="VISIBILITY:hidden; OVERFLOW:hidden; POSITION:absolute; WIDTH: 1px; HEIGHT: 1px"></div>
		<input type="hidden">
			<xsl:attribute name="name"><xsl:value-of select='@name'/></xsl:attribute>
			<xsl:attribute name="id"><xsl:value-of select="$thisid"/></xsl:attribute>
			<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
		</input>
	</xsl:template>

	<xsl:template name="x_editorObject">
	
		<object id="objContent" class="xed_text" classid="clsid:2D360201-FFF5-11D1-8D03-00A0C959BC0A" viewastext="true">
			<xsl:if test="parent::*/xedstyle/@val">
				<xsl:attribute name="class">xed_text_pg</xsl:attribute>
			</xsl:if>
			<param name="ActivateApplets" value="0" />
			<param name="ActivateActiveXControls" value="0" />
			<param name="ActivateDTCs" value="1" />
			<param name="ShowDetails" value="0" />
			<param name="ShowBorders" value="0" />
			<param name="Appearance" value="0" />
			<param name="Scrollbars" value="1" />
			<xsl:if test="parent::*/xedstyle/@val">
				<xsl:attribute name="value">0</xsl:attribute>
			</xsl:if>
			<param name="ScrollbarAppearance" value="1" />
			<param name="SourceCodePreservation" value="1" />
			<param name="AbsoluteDropMode" value="0" />
			<param name="SnapToGrid" value="0" />
			<param name="SnapToGridX" value="50" />
			<param name="SnapToGridY" value="50" />
			<param name="UseDivOnCarriageReturn" value="1" />
		</object>
	</xsl:template>
	
</xsl:stylesheet>
